VirtualBox

source: vbox/trunk/include/VBox/vmm/ssm.h@ 43262

Last change on this file since 43262 was 41900, checked in by vboxsync, 12 years ago

SSM: Added SSMFIELD_ENTRY_U32_ZX_U64.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 51.9 KB
Line 
1/** @file
2 * SSM - The Save State Manager.
3 */
4
5/*
6 * Copyright (C) 2006-2010 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___VBox_vmm_ssm_h
27#define ___VBox_vmm_ssm_h
28
29#include <VBox/types.h>
30#include <VBox/vmm/tm.h>
31#include <VBox/vmm/vmapi.h>
32
33
34RT_C_DECLS_BEGIN
35
36/** @defgroup grp_ssm The Saved State Manager API
37 * @{
38 */
39
40/**
41 * Determine the major version of the SSM version. If the major SSM version of two snapshots is
42 * different, the snapshots are incompatible.
43 */
44#define SSM_VERSION_MAJOR(ver) ((ver) & 0xffff0000)
45
46/**
47 * Determine the minor version of the SSM version. If the major SSM version of two snapshots is
48 * the same, the code must handle incompatibilies between minor version changes (e.g. use dummy
49 * values for non-existent fields).
50 */
51#define SSM_VERSION_MINOR(ver) ((ver) & 0x0000ffff)
52
53/**
54 * Determine if the major version changed between two SSM versions.
55 */
56#define SSM_VERSION_MAJOR_CHANGED(ver1,ver2) (SSM_VERSION_MAJOR(ver1) != SSM_VERSION_MAJOR(ver2))
57
58/** The special value for the final pass. */
59#define SSM_PASS_FINAL UINT32_MAX
60
61
62#ifdef IN_RING3
63/** @defgroup grp_ssm_r3 The SSM Host Context Ring-3 API
64 * @{
65 */
66
67
68/**
69 * What to do after the save/load operation.
70 */
71typedef enum SSMAFTER
72{
73 /** Invalid. */
74 SSMAFTER_INVALID = 0,
75 /** Will resume the loaded state. */
76 SSMAFTER_RESUME,
77 /** Will destroy the VM after saving. */
78 SSMAFTER_DESTROY,
79 /** Will continue execution after saving the VM. */
80 SSMAFTER_CONTINUE,
81 /** Will teleport the VM.
82 * The source VM will be destroyed (then one saving), the destination VM
83 * will continue execution. */
84 SSMAFTER_TELEPORT,
85 /** Will debug the saved state.
86 * This is used to drop some of the stricter consitentcy checks so it'll
87 * load fine in the debugger or animator. */
88 SSMAFTER_DEBUG_IT,
89 /** The file was opened using SSMR3Open() and we have no idea what the plan is. */
90 SSMAFTER_OPENED
91} SSMAFTER;
92
93
94/** Pointer to a structure field description. */
95typedef struct SSMFIELD *PSSMFIELD;
96/** Pointer to a const structure field description. */
97typedef const struct SSMFIELD *PCSSMFIELD;
98
99/**
100 * SSMFIELD Get/Put callback function.
101 *
102 * This is call for getting and putting the field it is associated with. It's
103 * up to the callback to work the saved state correctly.
104 *
105 * @returns VBox status code.
106 *
107 * @param pSSM The saved state handle.
108 * @param pField The field that is being processed.
109 * @param pvStruct Pointer to the structure.
110 * @param fFlags SSMSTRUCT_FLAGS_XXX.
111 * @param fGetOrPut True if getting, false if putting.
112 * @param pvUser The user argument specified to SSMR3GetStructEx or
113 * SSMR3PutStructEx.
114 */
115typedef DECLCALLBACK(int) FNSSMFIELDGETPUT(PSSMHANDLE pSSM, const struct SSMFIELD *pField, void *pvStruct,
116 uint32_t fFlags, bool fGetOrPut, void *pvUser);
117/** Pointer to a SSMFIELD Get/Put callback. */
118typedef FNSSMFIELDGETPUT *PFNSSMFIELDGETPUT;
119
120/**
121 * SSM field transformers.
122 *
123 * These are stored in the SSMFIELD::pfnGetPutOrTransformer and must therefore
124 * have values outside the valid pointer range.
125 */
126typedef enum SSMFIELDTRANS
127{
128 /** Invalid. */
129 SSMFIELDTRANS_INVALID = 0,
130 /** No transformation. */
131 SSMFIELDTRANS_NO_TRANSFORMATION,
132 /** Guest context (GC) physical address. */
133 SSMFIELDTRANS_GCPHYS,
134 /** Guest context (GC) virtual address. */
135 SSMFIELDTRANS_GCPTR,
136 /** Raw-mode context (RC) virtual address. */
137 SSMFIELDTRANS_RCPTR,
138 /** Array of raw-mode context (RC) virtual addresses. */
139 SSMFIELDTRANS_RCPTR_ARRAY,
140 /** Host context (HC) virtual address used as a NULL indicator. See
141 * SSMFIELD_ENTRY_HCPTR_NI. */
142 SSMFIELDTRANS_HCPTR_NI,
143 /** Array of SSMFIELDTRANS_HCPTR_NI. */
144 SSMFIELDTRANS_HCPTR_NI_ARRAY,
145 /** Host context (HC) virtual address used to hold a unsigned 32-bit value. */
146 SSMFIELDTRANS_HCPTR_HACK_U32,
147 /** Load a 32-bit unsigned filed from the state and zero extend it into a 64-bit
148 * structure member. */
149 SSMFIELDTRANS_U32_ZX_U64,
150
151 /** Ignorable field. See SSMFIELD_ENTRY_IGNORE. */
152 SSMFIELDTRANS_IGNORE,
153 /** Ignorable guest context (GC) physical address. */
154 SSMFIELDTRANS_IGN_GCPHYS,
155 /** Ignorable guest context (GC) virtual address. */
156 SSMFIELDTRANS_IGN_GCPTR,
157 /** Ignorable raw-mode context (RC) virtual address. */
158 SSMFIELDTRANS_IGN_RCPTR,
159 /** Ignorable host context (HC) virtual address. */
160 SSMFIELDTRANS_IGN_HCPTR,
161
162 /** Old field.
163 * Save as zeros and skip on restore (nowhere to restore it any longer). */
164 SSMFIELDTRANS_OLD,
165 /** Old guest context (GC) physical address. */
166 SSMFIELDTRANS_OLD_GCPHYS,
167 /** Old guest context (GC) virtual address. */
168 SSMFIELDTRANS_OLD_GCPTR,
169 /** Old raw-mode context (RC) virtual address. */
170 SSMFIELDTRANS_OLD_RCPTR,
171 /** Old host context (HC) virtual address. */
172 SSMFIELDTRANS_OLD_HCPTR,
173 /** Old host context specific padding.
174 * The lower word is the size of 32-bit hosts, the upper for 64-bit hosts. */
175 SSMFIELDTRANS_OLD_PAD_HC,
176 /** Old padding specific to the 32-bit Microsoft C Compiler. */
177 SSMFIELDTRANS_OLD_PAD_MSC32,
178
179 /** Padding that differs between 32-bit and 64-bit hosts.
180 * The first byte of SSMFIELD::cb contains the size for 32-bit hosts.
181 * The second byte of SSMFIELD::cb contains the size for 64-bit hosts.
182 * The upper word of SSMFIELD::cb contains the actual field size.
183 */
184 SSMFIELDTRANS_PAD_HC,
185 /** Padding for 32-bit hosts only.
186 * SSMFIELD::cb has the same format as for SSMFIELDTRANS_PAD_HC. */
187 SSMFIELDTRANS_PAD_HC32,
188 /** Padding for 64-bit hosts only.
189 * SSMFIELD::cb has the same format as for SSMFIELDTRANS_PAD_HC. */
190 SSMFIELDTRANS_PAD_HC64,
191 /** Automatic compiler padding that may differ between 32-bit and
192 * 64-bit hosts. SSMFIELD::cb has the same format as for
193 * SSMFIELDTRANS_PAD_HC. */
194 SSMFIELDTRANS_PAD_HC_AUTO,
195 /** Automatic compiler padding specific to the 32-bit Microsoft C
196 * compiler.
197 * SSMFIELD::cb has the same format as for SSMFIELDTRANS_PAD_HC. */
198 SSMFIELDTRANS_PAD_MSC32_AUTO
199} SSMFIELDTRANS;
200
201/** Tests if it's a padding field with the special SSMFIELD::cb format.
202 * @returns true / false.
203 * @param pfn The SSMFIELD::pfnGetPutOrTransformer value.
204 */
205#define SSMFIELDTRANS_IS_PADDING(pfn) \
206 ( (uintptr_t)(pfn) >= SSMFIELDTRANS_PAD_HC && (uintptr_t)(pfn) <= SSMFIELDTRANS_PAD_MSC32_AUTO )
207
208/** Tests if it's an entry for an old field.
209 *
210 * @returns true / false.
211 * @param pfn The SSMFIELD::pfnGetPutOrTransformer value.
212 */
213#define SSMFIELDTRANS_IS_OLD(pfn) \
214 ( (uintptr_t)(pfn) >= SSMFIELDTRANS_OLD && (uintptr_t)(pfn) <= SSMFIELDTRANS_OLD_PAD_MSC32 )
215
216/**
217 * A structure field description.
218 */
219typedef struct SSMFIELD
220{
221 /** Getter and putter callback or transformer index. */
222 PFNSSMFIELDGETPUT pfnGetPutOrTransformer;
223 /** Field offset into the structure. */
224 uint32_t off;
225 /** The size of the field. */
226 uint32_t cb;
227 /** Field name. */
228 const char *pszName;
229} SSMFIELD;
230
231/** Emit a SSMFIELD array entry.
232 * @internal */
233#define SSMFIELD_ENTRY_INT(Name, off, cb, enmTransformer) \
234 { (PFNSSMFIELDGETPUT)(uintptr_t)(enmTransformer), (off), (cb), Name }
235/** Emit a SSMFIELD array entry.
236 * @internal */
237#define SSMFIELD_ENTRY_TF_INT(Type, Field, enmTransformer) \
238 SSMFIELD_ENTRY_INT(#Type "::" #Field, RT_OFFSETOF(Type, Field), RT_SIZEOFMEMB(Type, Field), enmTransformer)
239/** Emit a SSMFIELD array entry for an old field.
240 * @internal */
241#define SSMFIELD_ENTRY_OLD_INT(Field, cb, enmTransformer) \
242 SSMFIELD_ENTRY_INT("old::" #Field, UINT32_MAX / 2, (cb), enmTransformer)
243/** Emit a SSMFIELD array entry for an alignment padding.
244 * @internal */
245#define SSMFIELD_ENTRY_PAD_INT(Type, Field, cb32, cb64, enmTransformer) \
246 SSMFIELD_ENTRY_INT(#Type "::" #Field, RT_OFFSETOF(Type, Field), \
247 (RT_SIZEOFMEMB(Type, Field) << 16) | (cb32) | ((cb64) << 8), enmTransformer)
248/** Emit a SSMFIELD array entry for an alignment padding.
249 * @internal */
250#define SSMFIELD_ENTRY_PAD_OTHER_INT(Type, Field, cb32, cb64, enmTransformer) \
251 SSMFIELD_ENTRY_INT(#Type "::" #Field, UINT32_MAX / 2, 0 | (cb32) | ((cb64) << 8), enmTransformer)
252
253/** Emit a SSMFIELD array entry. */
254#define SSMFIELD_ENTRY(Type, Field) SSMFIELD_ENTRY_TF_INT(Type, Field, SSMFIELDTRANS_NO_TRANSFORMATION)
255/** Emit a SSMFIELD array entry for a custom made field. This is intended
256 * for working around bitfields in old structures. */
257#define SSMFIELD_ENTRY_CUSTOM(Field, off, cb) SSMFIELD_ENTRY_INT("custom::" #Field, off, cb, SSMFIELDTRANS_NO_TRANSFORMATION)
258/** Emit a SSMFIELD array entry for a RTGCPHYS type. */
259#define SSMFIELD_ENTRY_GCPHYS(Type, Field) SSMFIELD_ENTRY_TF_INT(Type, Field, SSMFIELDTRANS_GCPHYS)
260/** Emit a SSMFIELD array entry for a RTGCPTR type. */
261#define SSMFIELD_ENTRY_GCPTR(Type, Field) SSMFIELD_ENTRY_TF_INT(Type, Field, SSMFIELDTRANS_GCPTR)
262/** Emit a SSMFIELD array entry for a raw-mode context pointer. */
263#define SSMFIELD_ENTRY_RCPTR(Type, Field) SSMFIELD_ENTRY_TF_INT(Type, Field, SSMFIELDTRANS_RCPTR)
264/** Emit a SSMFIELD array entry for a raw-mode context pointer. */
265#define SSMFIELD_ENTRY_RCPTR_ARRAY(Type, Field) SSMFIELD_ENTRY_TF_INT(Type, Field, SSMFIELDTRANS_RCPTR_ARRAY)
266/** Emit a SSMFIELD array entry for a ring-0 or ring-3 pointer type that is only
267 * of interest as a NULL indicator.
268 *
269 * This is always restored as a 0 (NULL) or 1 value. When
270 * SSMSTRUCT_FLAGS_DONT_IGNORE is set, the pointer will be saved in its
271 * entirety, when clear it will be saved as a boolean. */
272#define SSMFIELD_ENTRY_HCPTR_NI(Type, Field) SSMFIELD_ENTRY_TF_INT(Type, Field, SSMFIELDTRANS_HCPTR_NI)
273/** Same as SSMFIELD_ENTRY_HCPTR_NI, except it's an array of the buggers. */
274#define SSMFIELD_ENTRY_HCPTR_NI_ARRAY(Type, Field) SSMFIELD_ENTRY_TF_INT(Type, Field, SSMFIELDTRANS_HCPTR_NI_ARRAY)
275/** Emit a SSMFIELD array entry for a ring-0 or ring-3 pointer type that has
276 * been hacked such that it will never exceed 32-bit. No sign extending. */
277#define SSMFIELD_ENTRY_HCPTR_HACK_U32(Type, Field) SSMFIELD_ENTRY_TF_INT(Type, Field, SSMFIELDTRANS_HCPTR_HACK_U32)
278/** Emit a SSMFIELD array entry for loading a 32-bit field into a 64-bit
279 * structure member, zero extending the value. */
280#define SSMFIELD_ENTRY_U32_ZX_U64(Type, Field) SSMFIELD_ENTRY_TF_INT(Type, Field, SSMFIELDTRANS_U32_ZX_U64)
281
282/** Emit a SSMFIELD array entry for a field that can be ignored.
283 * It is stored as zeros if SSMSTRUCT_FLAGS_DONT_IGNORE is specified to
284 * SSMR3PutStructEx. The member is never touched upon restore. */
285#define SSMFIELD_ENTRY_IGNORE(Type, Field) SSMFIELD_ENTRY_TF_INT(Type, Field, SSMFIELDTRANS_IGNORE)
286/** Emit a SSMFIELD array entry for an ignorable RTGCPHYS type. */
287#define SSMFIELD_ENTRY_IGN_GCPHYS(Type, Field) SSMFIELD_ENTRY_TF_INT(Type, Field, SSMFIELDTRANS_IGN_GCPHYS)
288/** Emit a SSMFIELD array entry for an ignorable RTGCPHYS type. */
289#define SSMFIELD_ENTRY_IGN_GCPTR(Type, Field) SSMFIELD_ENTRY_TF_INT(Type, Field, SSMFIELDTRANS_IGN_GCPTR)
290/** Emit a SSMFIELD array entry for an ignorable raw-mode context pointer. */
291#define SSMFIELD_ENTRY_IGN_RCPTR(Type, Field) SSMFIELD_ENTRY_TF_INT(Type, Field, SSMFIELDTRANS_IGN_RCPTR)
292/** Emit a SSMFIELD array entry for an ignorable ring-3 or/and ring-0 pointer. */
293#define SSMFIELD_ENTRY_IGN_HCPTR(Type, Field) SSMFIELD_ENTRY_TF_INT(Type, Field, SSMFIELDTRANS_IGN_HCPTR)
294
295/** Emit a SSMFIELD array entry for an old field that should be ignored now.
296 * It is stored as zeros and skipped on load. */
297#define SSMFIELD_ENTRY_OLD(Field, cb) SSMFIELD_ENTRY_OLD_INT(Field, cb, SSMFIELDTRANS_OLD)
298/** Same as SSMFIELD_ENTRY_IGN_GCPHYS, except there is no structure field. */
299#define SSMFIELD_ENTRY_OLD_GCPHYS(Field) SSMFIELD_ENTRY_OLD_INT(Field, sizeof(RTGCPHYS), SSMFIELDTRANS_OLD_GCPHYS)
300/** Same as SSMFIELD_ENTRY_IGN_GCPTR, except there is no structure field. */
301#define SSMFIELD_ENTRY_OLD_GCPTR(Field) SSMFIELD_ENTRY_OLD_INT(Field, sizeof(RTGCPTR), SSMFIELDTRANS_OLD_GCPTR)
302/** Same as SSMFIELD_ENTRY_IGN_RCPTR, except there is no structure field. */
303#define SSMFIELD_ENTRY_OLD_RCPTR(Field) SSMFIELD_ENTRY_OLD_INT(Field, sizeof(RTRCPTR), SSMFIELDTRANS_OLD_RCPTR)
304/** Same as SSMFIELD_ENTRY_IGN_HCPTR, except there is no structure field. */
305#define SSMFIELD_ENTRY_OLD_HCPTR(Field) SSMFIELD_ENTRY_OLD_INT(Field, sizeof(RTHCPTR), SSMFIELDTRANS_OLD_HCPTR)
306/** Same as SSMFIELD_ENTRY_PAD_HC, except there is no structure field. */
307#define SSMFIELD_ENTRY_OLD_PAD_HC(Field, cb32, cb64) \
308 SSMFIELD_ENTRY_OLD_INT(Field, RT_MAKE_U32((cb32), (cb64)), SSMFIELDTRANS_OLD_PAD_HC)
309/** Same as SSMFIELD_ENTRY_PAD_HC64, except there is no structure field. */
310#define SSMFIELD_ENTRY_OLD_PAD_HC64(Field, cb) SSMFIELD_ENTRY_OLD_PAD_HC(Field, 0, cb)
311/** Same as SSMFIELD_ENTRY_PAD_HC32, except there is no structure field. */
312#define SSMFIELD_ENTRY_OLD_PAD_HC32(Field, cb) SSMFIELD_ENTRY_OLD_PAD_HC(Field, cb, 0)
313/** Same as SSMFIELD_ENTRY_PAD_HC, except there is no structure field. */
314#define SSMFIELD_ENTRY_OLD_PAD_MSC32(Field, cb) SSMFIELD_ENTRY_OLD_INT(Field, cb, SSMFIELDTRANS_OLD_PAD_MSC32)
315
316/** Emit a SSMFIELD array entry for a padding that differs in size between
317 * 64-bit and 32-bit hosts. */
318#define SSMFIELD_ENTRY_PAD_HC(Type, Field, cb32, cb64) SSMFIELD_ENTRY_PAD_INT( Type, Field, cb32, cb64, SSMFIELDTRANS_PAD_HC)
319/** Emit a SSMFIELD array entry for a padding that is exclusive to 64-bit hosts. */
320#if HC_ARCH_BITS == 64
321# define SSMFIELD_ENTRY_PAD_HC64(Type, Field, cb) SSMFIELD_ENTRY_PAD_INT( Type, Field, 0, cb, SSMFIELDTRANS_PAD_HC64)
322#else
323# define SSMFIELD_ENTRY_PAD_HC64(Type, Field, cb) SSMFIELD_ENTRY_PAD_OTHER_INT(Type, Field, 0, cb, SSMFIELDTRANS_PAD_HC64)
324#endif
325/** Emit a SSMFIELD array entry for a 32-bit padding for on 64-bits hosts. */
326#if HC_ARCH_BITS == 32
327# define SSMFIELD_ENTRY_PAD_HC32(Type, Field, cb) SSMFIELD_ENTRY_PAD_INT( Type, Field, cb, 0, SSMFIELDTRANS_PAD_HC32)
328#else
329# define SSMFIELD_ENTRY_PAD_HC32(Type, Field, cb) SSMFIELD_ENTRY_PAD_OTHER_INT(Type, Field, cb, 0, SSMFIELDTRANS_PAD_HC32)
330#endif
331/** Emit a SSMFIELD array entry for an automatic compiler padding that may
332 * differ in size between 64-bit and 32-bit hosts. */
333#if HC_ARCH_BITS == 64
334# define SSMFIELD_ENTRY_PAD_HC_AUTO(cb32, cb64) \
335 { \
336 (PFNSSMFIELDGETPUT)(uintptr_t)(SSMFIELDTRANS_PAD_HC_AUTO), \
337 UINT32_MAX / 2, (cb64 << 16) | (cb32) | ((cb64) << 8), "<compiler-padding>" \
338 }
339#else
340# define SSMFIELD_ENTRY_PAD_HC_AUTO(cb32, cb64) \
341 { \
342 (PFNSSMFIELDGETPUT)(uintptr_t)(SSMFIELDTRANS_PAD_HC_AUTO), \
343 UINT32_MAX / 2, (cb32 << 16) | (cb32) | ((cb64) << 8), "<compiler-padding>" \
344 }
345#endif
346/** Emit a SSMFIELD array entry for an automatic compiler padding that is unique
347 * to the 32-bit microsoft compiler. This is usually used together with
348 * SSMFIELD_ENTRY_PAD_HC*. */
349#if HC_ARCH_BITS == 32 && defined(_MSC_VER)
350# define SSMFIELD_ENTRY_PAD_MSC32_AUTO(cb) \
351 { \
352 (PFNSSMFIELDGETPUT)(uintptr_t)(SSMFIELDTRANS_PAD_MSC32_AUTO), \
353 UINT32_MAX / 2, ((cb) << 16) | (cb), "<msc32-padding>" \
354 }
355#else
356# define SSMFIELD_ENTRY_PAD_MSC32_AUTO(cb) \
357 { \
358 (PFNSSMFIELDGETPUT)(uintptr_t)(SSMFIELDTRANS_PAD_MSC32_AUTO), \
359 UINT32_MAX / 2, (cb), "<msc32-padding>" \
360 }
361#endif
362
363/** Emit a SSMFIELD array entry for a field with a custom callback. */
364#define SSMFIELD_ENTRY_CALLBACK(Type, Field, pfnGetPut) \
365 { (pfnGetPut), RT_OFFSETOF(Type, Field), RT_SIZEOFMEMB(Type, Field), #Type "::" #Field }
366/** Emit the terminating entry of a SSMFIELD array. */
367#define SSMFIELD_ENTRY_TERM() { (PFNSSMFIELDGETPUT)(uintptr_t)SSMFIELDTRANS_INVALID, UINT32_MAX, UINT32_MAX, NULL }
368
369
370/** @name SSMR3GetStructEx and SSMR3PutStructEx flags.
371 * @{ */
372/** The field descriptors must exactly cover the entire struct, A to Z. */
373#define SSMSTRUCT_FLAGS_FULL_STRUCT RT_BIT_32(0)
374/** No start and end markers, just the raw bits. */
375#define SSMSTRUCT_FLAGS_NO_MARKERS RT_BIT_32(1)
376/** Do not ignore any ignorable fields. */
377#define SSMSTRUCT_FLAGS_DONT_IGNORE RT_BIT_32(2)
378/** Saved using SSMR3PutMem, don't be too strict. */
379#define SSMSTRUCT_FLAGS_SAVED_AS_MEM RT_BIT_32(3)
380/** Band-aid for old SSMR3PutMem/SSMR3GetMem of structurs with host pointers. */
381#define SSMSTRUCT_FLAGS_MEM_BAND_AID ( SSMSTRUCT_FLAGS_DONT_IGNORE | SSMSTRUCT_FLAGS_FULL_STRUCT \
382 | SSMSTRUCT_FLAGS_NO_MARKERS | SSMSTRUCT_FLAGS_SAVED_AS_MEM)
383/** Band-aid for old SSMR3PutMem/SSMR3GetMem of structurs with host
384 * pointers, with relaxed checks. */
385#define SSMSTRUCT_FLAGS_MEM_BAND_AID_RELAXED ( SSMSTRUCT_FLAGS_DONT_IGNORE \
386 | SSMSTRUCT_FLAGS_NO_MARKERS | SSMSTRUCT_FLAGS_SAVED_AS_MEM)
387/** Mask of the valid bits. */
388#define SSMSTRUCT_FLAGS_VALID_MASK UINT32_C(0x0000000f)
389/** @} */
390
391
392/** The PDM Device callback variants.
393 * @{
394 */
395
396/**
397 * Prepare state live save operation.
398 *
399 * @returns VBox status code.
400 * @param pDevIns Device instance of the device which registered the data unit.
401 * @param pSSM SSM operation handle.
402 * @thread Any.
403 */
404typedef DECLCALLBACK(int) FNSSMDEVLIVEPREP(PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
405/** Pointer to a FNSSMDEVLIVEPREP() function. */
406typedef FNSSMDEVLIVEPREP *PFNSSMDEVLIVEPREP;
407
408/**
409 * Execute state live save operation.
410 *
411 * This will be called repeatedly until all units vote that the live phase has
412 * been concluded.
413 *
414 * @returns VBox status code.
415 * @param pDevIns Device instance of the device which registered the data unit.
416 * @param pSSM SSM operation handle.
417 * @param uPass The pass.
418 * @thread Any.
419 */
420typedef DECLCALLBACK(int) FNSSMDEVLIVEEXEC(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass);
421/** Pointer to a FNSSMDEVLIVEEXEC() function. */
422typedef FNSSMDEVLIVEEXEC *PFNSSMDEVLIVEEXEC;
423
424/**
425 * Vote on whether the live part of the saving has been concluded.
426 *
427 * The vote stops once a unit has vetoed the decision, so don't rely upon this
428 * being called every time.
429 *
430 * @returns VBox status code.
431 * @retval VINF_SUCCESS if done.
432 * @retval VINF_SSM_VOTE_FOR_ANOTHER_PASS if another pass is needed.
433 * @retval VINF_SSM_VOTE_DONE_DONT_CALL_AGAIN if the live saving of the unit is
434 * done and there is not need calling it again before the final pass.
435 * @retval VERR_SSM_VOTE_FOR_GIVING_UP if its time to give up.
436 *
437 * @param pDevIns Device instance of the device which registered the data unit.
438 * @param pSSM SSM operation handle.
439 * @param uPass The data pass.
440 * @thread Any.
441 */
442typedef DECLCALLBACK(int) FNSSMDEVLIVEVOTE(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass);
443/** Pointer to a FNSSMDEVLIVEVOTE() function. */
444typedef FNSSMDEVLIVEVOTE *PFNSSMDEVLIVEVOTE;
445
446/**
447 * Prepare state save operation.
448 *
449 * @returns VBox status code.
450 * @param pDevIns Device instance of the device which registered the data unit.
451 * @param pSSM SSM operation handle.
452 */
453typedef DECLCALLBACK(int) FNSSMDEVSAVEPREP(PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
454/** Pointer to a FNSSMDEVSAVEPREP() function. */
455typedef FNSSMDEVSAVEPREP *PFNSSMDEVSAVEPREP;
456
457/**
458 * Execute state save operation.
459 *
460 * @returns VBox status code.
461 * @param pDevIns Device instance of the device which registered the data unit.
462 * @param pSSM SSM operation handle.
463 */
464typedef DECLCALLBACK(int) FNSSMDEVSAVEEXEC(PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
465/** Pointer to a FNSSMDEVSAVEEXEC() function. */
466typedef FNSSMDEVSAVEEXEC *PFNSSMDEVSAVEEXEC;
467
468/**
469 * Done state save operation.
470 *
471 * @returns VBox status code.
472 * @param pDevIns Device instance of the device which registered the data unit.
473 * @param pSSM SSM operation handle.
474 */
475typedef DECLCALLBACK(int) FNSSMDEVSAVEDONE(PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
476/** Pointer to a FNSSMDEVSAVEDONE() function. */
477typedef FNSSMDEVSAVEDONE *PFNSSMDEVSAVEDONE;
478
479/**
480 * Prepare state load operation.
481 *
482 * @returns VBox status code.
483 * @param pDevIns Device instance of the device which registered the data unit.
484 * @param pSSM SSM operation handle.
485 */
486typedef DECLCALLBACK(int) FNSSMDEVLOADPREP(PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
487/** Pointer to a FNSSMDEVLOADPREP() function. */
488typedef FNSSMDEVLOADPREP *PFNSSMDEVLOADPREP;
489
490/**
491 * Execute state load operation.
492 *
493 * @returns VBox status code.
494 * @param pDevIns Device instance of the device which registered the data unit.
495 * @param pSSM SSM operation handle.
496 * @param uVersion Data layout version.
497 * @param uPass The pass. This is always SSM_PASS_FINAL for units
498 * that doesn't specify a pfnSaveLive callback.
499 */
500typedef DECLCALLBACK(int) FNSSMDEVLOADEXEC(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
501/** Pointer to a FNSSMDEVLOADEXEC() function. */
502typedef FNSSMDEVLOADEXEC *PFNSSMDEVLOADEXEC;
503
504/**
505 * Done state load operation.
506 *
507 * @returns VBox load code.
508 * @param pDevIns Device instance of the device which registered the data unit.
509 * @param pSSM SSM operation handle.
510 */
511typedef DECLCALLBACK(int) FNSSMDEVLOADDONE(PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
512/** Pointer to a FNSSMDEVLOADDONE() function. */
513typedef FNSSMDEVLOADDONE *PFNSSMDEVLOADDONE;
514
515/** @} */
516
517
518/** The PDM USB device callback variants.
519 * @{
520 */
521
522/**
523 * Prepare state live save operation.
524 *
525 * @returns VBox status code.
526 * @param pUsbIns The USB device instance of the USB device which
527 * registered the data unit.
528 * @param pSSM SSM operation handle.
529 * @thread Any.
530 */
531typedef DECLCALLBACK(int) FNSSMUSBLIVEPREP(PPDMUSBINS pUsbIns, PSSMHANDLE pSSM);
532/** Pointer to a FNSSMUSBLIVEPREP() function. */
533typedef FNSSMUSBLIVEPREP *PFNSSMUSBLIVEPREP;
534
535/**
536 * Execute state live save operation.
537 *
538 * This will be called repeatedly until all units vote that the live phase has
539 * been concluded.
540 *
541 * @returns VBox status code.
542 * @param pUsbIns The USB device instance of the USB device which
543 * registered the data unit.
544 * @param pSSM SSM operation handle.
545 * @param uPass The pass.
546 * @thread Any.
547 */
548typedef DECLCALLBACK(int) FNSSMUSBLIVEEXEC(PPDMUSBINS pUsbIns, PSSMHANDLE pSSM, uint32_t uPass);
549/** Pointer to a FNSSMUSBLIVEEXEC() function. */
550typedef FNSSMUSBLIVEEXEC *PFNSSMUSBLIVEEXEC;
551
552/**
553 * Vote on whether the live part of the saving has been concluded.
554 *
555 * The vote stops once a unit has vetoed the decision, so don't rely upon this
556 * being called every time.
557 *
558 * @returns VBox status code.
559 * @retval VINF_SUCCESS if done.
560 * @retval VINF_SSM_VOTE_FOR_ANOTHER_PASS if another pass is needed.
561 * @retval VINF_SSM_VOTE_DONE_DONT_CALL_AGAIN if the live saving of the unit is
562 * done and there is not need calling it again before the final pass.
563 * @retval VERR_SSM_VOTE_FOR_GIVING_UP if its time to give up.
564 *
565 * @param pUsbIns The USB device instance of the USB device which
566 * registered the data unit.
567 * @param pSSM SSM operation handle.
568 * @param uPass The data pass.
569 * @thread Any.
570 */
571typedef DECLCALLBACK(int) FNSSMUSBLIVEVOTE(PPDMUSBINS pUsbIns, PSSMHANDLE pSSM, uint32_t uPass);
572/** Pointer to a FNSSMUSBLIVEVOTE() function. */
573typedef FNSSMUSBLIVEVOTE *PFNSSMUSBLIVEVOTE;
574
575/**
576 * Prepare state save operation.
577 *
578 * @returns VBox status code.
579 * @param pUsbIns The USB device instance of the USB device which
580 * registered the data unit.
581 * @param pSSM SSM operation handle.
582 */
583typedef DECLCALLBACK(int) FNSSMUSBSAVEPREP(PPDMUSBINS pUsbIns, PSSMHANDLE pSSM);
584/** Pointer to a FNSSMUSBSAVEPREP() function. */
585typedef FNSSMUSBSAVEPREP *PFNSSMUSBSAVEPREP;
586
587/**
588 * Execute state save operation.
589 *
590 * @returns VBox status code.
591 * @param pUsbIns The USB device instance of the USB device which
592 * registered the data unit.
593 * @param pSSM SSM operation handle.
594 */
595typedef DECLCALLBACK(int) FNSSMUSBSAVEEXEC(PPDMUSBINS pUsbIns, PSSMHANDLE pSSM);
596/** Pointer to a FNSSMUSBSAVEEXEC() function. */
597typedef FNSSMUSBSAVEEXEC *PFNSSMUSBSAVEEXEC;
598
599/**
600 * Done state save operation.
601 *
602 * @returns VBox status code.
603 * @param pUsbIns The USB device instance of the USB device which
604 * registered the data unit.
605 * @param pSSM SSM operation handle.
606 */
607typedef DECLCALLBACK(int) FNSSMUSBSAVEDONE(PPDMUSBINS pUsbIns, PSSMHANDLE pSSM);
608/** Pointer to a FNSSMUSBSAVEDONE() function. */
609typedef FNSSMUSBSAVEDONE *PFNSSMUSBSAVEDONE;
610
611/**
612 * Prepare state load operation.
613 *
614 * @returns VBox status code.
615 * @param pUsbIns The USB device instance of the USB device which
616 * registered the data unit.
617 * @param pSSM SSM operation handle.
618 */
619typedef DECLCALLBACK(int) FNSSMUSBLOADPREP(PPDMUSBINS pUsbIns, PSSMHANDLE pSSM);
620/** Pointer to a FNSSMUSBLOADPREP() function. */
621typedef FNSSMUSBLOADPREP *PFNSSMUSBLOADPREP;
622
623/**
624 * Execute state load operation.
625 *
626 * @returns VBox status code.
627 * @param pUsbIns The USB device instance of the USB device which
628 * registered the data unit.
629 * @param pSSM SSM operation handle.
630 * @param uVersion Data layout version.
631 * @param uPass The pass. This is always SSM_PASS_FINAL for units
632 * that doesn't specify a pfnSaveLive callback.
633 */
634typedef DECLCALLBACK(int) FNSSMUSBLOADEXEC(PPDMUSBINS pUsbIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
635/** Pointer to a FNSSMUSBLOADEXEC() function. */
636typedef FNSSMUSBLOADEXEC *PFNSSMUSBLOADEXEC;
637
638/**
639 * Done state load operation.
640 *
641 * @returns VBox load code.
642 * @param pUsbIns The USB device instance of the USB device which
643 * registered the data unit.
644 * @param pSSM SSM operation handle.
645 */
646typedef DECLCALLBACK(int) FNSSMUSBLOADDONE(PPDMUSBINS pUsbIns, PSSMHANDLE pSSM);
647/** Pointer to a FNSSMUSBLOADDONE() function. */
648typedef FNSSMUSBLOADDONE *PFNSSMUSBLOADDONE;
649
650/** @} */
651
652
653/** The PDM Driver callback variants.
654 * @{
655 */
656
657/**
658 * Prepare state live save operation.
659 *
660 * @returns VBox status code.
661 * @param pDrvIns Driver instance of the driver which registered the
662 * data unit.
663 * @param pSSM SSM operation handle.
664 * @thread Any.
665 */
666typedef DECLCALLBACK(int) FNSSMDRVLIVEPREP(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM);
667/** Pointer to a FNSSMDRVLIVEPREP() function. */
668typedef FNSSMDRVLIVEPREP *PFNSSMDRVLIVEPREP;
669
670/**
671 * Execute state live save operation.
672 *
673 * This will be called repeatedly until all units vote that the live phase has
674 * been concluded.
675 *
676 * @returns VBox status code.
677 * @param pDrvIns Driver instance of the driver which registered the
678 * data unit.
679 * @param pSSM SSM operation handle.
680 * @param uPass The data pass.
681 * @thread Any.
682 */
683typedef DECLCALLBACK(int) FNSSMDRVLIVEEXEC(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM, uint32_t uPass);
684/** Pointer to a FNSSMDRVLIVEEXEC() function. */
685typedef FNSSMDRVLIVEEXEC *PFNSSMDRVLIVEEXEC;
686
687/**
688 * Vote on whether the live part of the saving has been concluded.
689 *
690 * The vote stops once a unit has vetoed the decision, so don't rely upon this
691 * being called every time.
692 *
693 * @returns VBox status code.
694 * @retval VINF_SUCCESS if done.
695 * @retval VINF_SSM_VOTE_FOR_ANOTHER_PASS if another pass is needed.
696 * @retval VINF_SSM_VOTE_DONE_DONT_CALL_AGAIN if the live saving of the unit is
697 * done and there is not need calling it again before the final pass.
698 * @retval VERR_SSM_VOTE_FOR_GIVING_UP if its time to give up.
699 *
700 * @param pDrvIns Driver instance of the driver which registered the
701 * data unit.
702 * @param pSSM SSM operation handle.
703 * @param uPass The data pass.
704 * @thread Any.
705 */
706typedef DECLCALLBACK(int) FNSSMDRVLIVEVOTE(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM, uint32_t uPass);
707/** Pointer to a FNSSMDRVLIVEVOTE() function. */
708typedef FNSSMDRVLIVEVOTE *PFNSSMDRVLIVEVOTE;
709
710
711/**
712 * Prepare state save operation.
713 *
714 * @returns VBox status code.
715 * @param pDrvIns Driver instance of the driver which registered the data unit.
716 * @param pSSM SSM operation handle.
717 */
718typedef DECLCALLBACK(int) FNSSMDRVSAVEPREP(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM);
719/** Pointer to a FNSSMDRVSAVEPREP() function. */
720typedef FNSSMDRVSAVEPREP *PFNSSMDRVSAVEPREP;
721
722/**
723 * Execute state save operation.
724 *
725 * @returns VBox status code.
726 * @param pDrvIns Driver instance of the driver which registered the data unit.
727 * @param pSSM SSM operation handle.
728 */
729typedef DECLCALLBACK(int) FNSSMDRVSAVEEXEC(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM);
730/** Pointer to a FNSSMDRVSAVEEXEC() function. */
731typedef FNSSMDRVSAVEEXEC *PFNSSMDRVSAVEEXEC;
732
733/**
734 * Done state save operation.
735 *
736 * @returns VBox status code.
737 * @param pDrvIns Driver instance of the driver which registered the data unit.
738 * @param pSSM SSM operation handle.
739 */
740typedef DECLCALLBACK(int) FNSSMDRVSAVEDONE(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM);
741/** Pointer to a FNSSMDRVSAVEDONE() function. */
742typedef FNSSMDRVSAVEDONE *PFNSSMDRVSAVEDONE;
743
744/**
745 * Prepare state load operation.
746 *
747 * @returns VBox status code.
748 * @param pDrvIns Driver instance of the driver which registered the data unit.
749 * @param pSSM SSM operation handle.
750 */
751typedef DECLCALLBACK(int) FNSSMDRVLOADPREP(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM);
752/** Pointer to a FNSSMDRVLOADPREP() function. */
753typedef FNSSMDRVLOADPREP *PFNSSMDRVLOADPREP;
754
755/**
756 * Execute state load operation.
757 *
758 * @returns VBox status code.
759 * @param pDrvIns Driver instance of the driver which registered the data unit.
760 * @param pSSM SSM operation handle.
761 * @param uVersion Data layout version.
762 * @param uPass The pass. This is always SSM_PASS_FINAL for units
763 * that doesn't specify a pfnSaveLive callback.
764 */
765typedef DECLCALLBACK(int) FNSSMDRVLOADEXEC(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
766/** Pointer to a FNSSMDRVLOADEXEC() function. */
767typedef FNSSMDRVLOADEXEC *PFNSSMDRVLOADEXEC;
768
769/**
770 * Done state load operation.
771 *
772 * @returns VBox load code.
773 * @param pDrvIns Driver instance of the driver which registered the data unit.
774 * @param pSSM SSM operation handle.
775 */
776typedef DECLCALLBACK(int) FNSSMDRVLOADDONE(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM);
777/** Pointer to a FNSSMDRVLOADDONE() function. */
778typedef FNSSMDRVLOADDONE *PFNSSMDRVLOADDONE;
779
780/** @} */
781
782
783/** The internal callback variants.
784 * @{
785 */
786
787
788/**
789 * Prepare state live save operation.
790 *
791 * @returns VBox status code.
792 * @param pVM VM Handle.
793 * @param pSSM SSM operation handle.
794 * @thread Any.
795 */
796typedef DECLCALLBACK(int) FNSSMINTLIVEPREP(PVM pVM, PSSMHANDLE pSSM);
797/** Pointer to a FNSSMINTLIVEPREP() function. */
798typedef FNSSMINTLIVEPREP *PFNSSMINTLIVEPREP;
799
800/**
801 * Execute state live save operation.
802 *
803 * This will be called repeatedly until all units vote that the live phase has
804 * been concluded.
805 *
806 * @returns VBox status code.
807 * @param pVM VM Handle.
808 * @param pSSM SSM operation handle.
809 * @param uPass The data pass.
810 * @thread Any.
811 */
812typedef DECLCALLBACK(int) FNSSMINTLIVEEXEC(PVM pVM, PSSMHANDLE pSSM, uint32_t uPass);
813/** Pointer to a FNSSMINTLIVEEXEC() function. */
814typedef FNSSMINTLIVEEXEC *PFNSSMINTLIVEEXEC;
815
816/**
817 * Vote on whether the live part of the saving has been concluded.
818 *
819 * The vote stops once a unit has vetoed the decision, so don't rely upon this
820 * being called every time.
821 *
822 * @returns VBox status code.
823 * @retval VINF_SUCCESS if done.
824 * @retval VINF_SSM_VOTE_FOR_ANOTHER_PASS if another pass is needed.
825 * @retval VINF_SSM_VOTE_DONE_DONT_CALL_AGAIN if the live saving of the unit is
826 * done and there is not need calling it again before the final pass.
827 * @retval VERR_SSM_VOTE_FOR_GIVING_UP if its time to give up.
828 *
829 * @param pVM VM Handle.
830 * @param pSSM SSM operation handle.
831 * @param uPass The data pass.
832 * @thread Any.
833 */
834typedef DECLCALLBACK(int) FNSSMINTLIVEVOTE(PVM pVM, PSSMHANDLE pSSM, uint32_t uPass);
835/** Pointer to a FNSSMINTLIVEVOTE() function. */
836typedef FNSSMINTLIVEVOTE *PFNSSMINTLIVEVOTE;
837
838/**
839 * Prepare state save operation.
840 *
841 * @returns VBox status code.
842 * @param pVM VM Handle.
843 * @param pSSM SSM operation handle.
844 */
845typedef DECLCALLBACK(int) FNSSMINTSAVEPREP(PVM pVM, PSSMHANDLE pSSM);
846/** Pointer to a FNSSMINTSAVEPREP() function. */
847typedef FNSSMINTSAVEPREP *PFNSSMINTSAVEPREP;
848
849/**
850 * Execute state save operation.
851 *
852 * @returns VBox status code.
853 * @param pVM VM Handle.
854 * @param pSSM SSM operation handle.
855 */
856typedef DECLCALLBACK(int) FNSSMINTSAVEEXEC(PVM pVM, PSSMHANDLE pSSM);
857/** Pointer to a FNSSMINTSAVEEXEC() function. */
858typedef FNSSMINTSAVEEXEC *PFNSSMINTSAVEEXEC;
859
860/**
861 * Done state save operation.
862 *
863 * @returns VBox status code.
864 * @param pVM VM Handle.
865 * @param pSSM SSM operation handle.
866 */
867typedef DECLCALLBACK(int) FNSSMINTSAVEDONE(PVM pVM, PSSMHANDLE pSSM);
868/** Pointer to a FNSSMINTSAVEDONE() function. */
869typedef FNSSMINTSAVEDONE *PFNSSMINTSAVEDONE;
870
871/**
872 * Prepare state load operation.
873 *
874 * @returns VBox status code.
875 * @param pVM VM Handle.
876 * @param pSSM SSM operation handle.
877 */
878typedef DECLCALLBACK(int) FNSSMINTLOADPREP(PVM pVM, PSSMHANDLE pSSM);
879/** Pointer to a FNSSMINTLOADPREP() function. */
880typedef FNSSMINTLOADPREP *PFNSSMINTLOADPREP;
881
882/**
883 * Execute state load operation.
884 *
885 * @returns VBox status code.
886 * @param pVM VM Handle.
887 * @param pSSM SSM operation handle.
888 * @param uVersion Data layout version.
889 * @param uPass The pass. This is always SSM_PASS_FINAL for units
890 * that doesn't specify a pfnSaveLive callback.
891 */
892typedef DECLCALLBACK(int) FNSSMINTLOADEXEC(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
893/** Pointer to a FNSSMINTLOADEXEC() function. */
894typedef FNSSMINTLOADEXEC *PFNSSMINTLOADEXEC;
895
896/**
897 * Done state load operation.
898 *
899 * @returns VBox load code.
900 * @param pVM VM Handle.
901 * @param pSSM SSM operation handle.
902 */
903typedef DECLCALLBACK(int) FNSSMINTLOADDONE(PVM pVM, PSSMHANDLE pSSM);
904/** Pointer to a FNSSMINTLOADDONE() function. */
905typedef FNSSMINTLOADDONE *PFNSSMINTLOADDONE;
906
907/** @} */
908
909
910/** The External callback variants.
911 * @{
912 */
913
914/**
915 * Prepare state live save operation.
916 *
917 * @returns VBox status code.
918 * @param pSSM SSM operation handle.
919 * @param pvUser User argument.
920 * @thread Any.
921 */
922typedef DECLCALLBACK(int) FNSSMEXTLIVEPREP(PSSMHANDLE pSSM, void *pvUser);
923/** Pointer to a FNSSMEXTLIVEPREP() function. */
924typedef FNSSMEXTLIVEPREP *PFNSSMEXTLIVEPREP;
925
926/**
927 * Execute state live save operation.
928 *
929 * This will be called repeatedly until all units vote that the live phase has
930 * been concluded.
931 *
932 * @returns VBox status code.
933 * @param pSSM SSM operation handle.
934 * @param pvUser User argument.
935 * @param uPass The data pass.
936 * @thread Any.
937 */
938typedef DECLCALLBACK(int) FNSSMEXTLIVEEXEC(PSSMHANDLE pSSM, void *pvUser, uint32_t uPass);
939/** Pointer to a FNSSMEXTLIVEEXEC() function. */
940typedef FNSSMEXTLIVEEXEC *PFNSSMEXTLIVEEXEC;
941
942/**
943 * Vote on whether the live part of the saving has been concluded.
944 *
945 * The vote stops once a unit has vetoed the decision, so don't rely upon this
946 * being called every time.
947 *
948 * @returns VBox status code.
949 * @retval VINF_SUCCESS if done.
950 * @retval VINF_SSM_VOTE_FOR_ANOTHER_PASS if another pass is needed.
951 * @retval VINF_SSM_VOTE_DONE_DONT_CALL_AGAIN if the live saving of the unit is
952 * done and there is not need calling it again before the final pass.
953 * @retval VERR_SSM_VOTE_FOR_GIVING_UP if its time to give up.
954 *
955 * @param pSSM SSM operation handle.
956 * @param pvUser User argument.
957 * @param uPass The data pass.
958 * @thread Any.
959 */
960typedef DECLCALLBACK(int) FNSSMEXTLIVEVOTE(PSSMHANDLE pSSM, void *pvUser, uint32_t uPass);
961/** Pointer to a FNSSMEXTLIVEVOTE() function. */
962typedef FNSSMEXTLIVEVOTE *PFNSSMEXTLIVEVOTE;
963
964/**
965 * Prepare state save operation.
966 *
967 * @returns VBox status code.
968 * @param pSSM SSM operation handle.
969 * @param pvUser User argument.
970 */
971typedef DECLCALLBACK(int) FNSSMEXTSAVEPREP(PSSMHANDLE pSSM, void *pvUser);
972/** Pointer to a FNSSMEXTSAVEPREP() function. */
973typedef FNSSMEXTSAVEPREP *PFNSSMEXTSAVEPREP;
974
975/**
976 * Execute state save operation.
977 *
978 * @param pSSM SSM operation handle.
979 * @param pvUser User argument.
980 * @author The lack of return code is for legacy reasons.
981 */
982typedef DECLCALLBACK(void) FNSSMEXTSAVEEXEC(PSSMHANDLE pSSM, void *pvUser);
983/** Pointer to a FNSSMEXTSAVEEXEC() function. */
984typedef FNSSMEXTSAVEEXEC *PFNSSMEXTSAVEEXEC;
985
986/**
987 * Done state save operation.
988 *
989 * @returns VBox status code.
990 * @param pSSM SSM operation handle.
991 * @param pvUser User argument.
992 */
993typedef DECLCALLBACK(int) FNSSMEXTSAVEDONE(PSSMHANDLE pSSM, void *pvUser);
994/** Pointer to a FNSSMEXTSAVEDONE() function. */
995typedef FNSSMEXTSAVEDONE *PFNSSMEXTSAVEDONE;
996
997/**
998 * Prepare state load operation.
999 *
1000 * @returns VBox status code.
1001 * @param pSSM SSM operation handle.
1002 * @param pvUser User argument.
1003 */
1004typedef DECLCALLBACK(int) FNSSMEXTLOADPREP(PSSMHANDLE pSSM, void *pvUser);
1005/** Pointer to a FNSSMEXTLOADPREP() function. */
1006typedef FNSSMEXTLOADPREP *PFNSSMEXTLOADPREP;
1007
1008/**
1009 * Execute state load operation.
1010 *
1011 * @returns VBox status code.
1012 * @param pSSM SSM operation handle.
1013 * @param pvUser User argument.
1014 * @param uVersion Data layout version.
1015 * @param uPass The pass. This is always SSM_PASS_FINAL for units
1016 * that doesn't specify a pfnSaveLive callback.
1017 * @remark The odd return value is for legacy reasons.
1018 */
1019typedef DECLCALLBACK(int) FNSSMEXTLOADEXEC(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
1020/** Pointer to a FNSSMEXTLOADEXEC() function. */
1021typedef FNSSMEXTLOADEXEC *PFNSSMEXTLOADEXEC;
1022
1023/**
1024 * Done state load operation.
1025 *
1026 * @returns VBox load code.
1027 * @param pSSM SSM operation handle.
1028 * @param pvUser User argument.
1029 */
1030typedef DECLCALLBACK(int) FNSSMEXTLOADDONE(PSSMHANDLE pSSM, void *pvUser);
1031/** Pointer to a FNSSMEXTLOADDONE() function. */
1032typedef FNSSMEXTLOADDONE *PFNSSMEXTLOADDONE;
1033
1034/** @} */
1035
1036
1037/**
1038 * SSM stream method table.
1039 *
1040 * This is used by external parties for teleporting over TCP or any other media.
1041 * SSM also uses this internally for file access, thus the 2-3 file centric
1042 * methods.
1043 */
1044typedef struct SSMSTRMOPS
1045{
1046 /** Struct magic + version (SSMSTRMOPS_VERSION). */
1047 uint32_t u32Version;
1048
1049 /**
1050 * Write bytes to the stream.
1051 *
1052 * @returns VBox status code.
1053 * @param pvUser The user argument.
1054 * @param offStream The stream offset we're (supposed to be) at.
1055 * @param pvBuf Pointer to the data.
1056 * @param cbToWrite The number of bytes to write.
1057 */
1058 DECLCALLBACKMEMBER(int, pfnWrite)(void *pvUser, uint64_t offStream, const void *pvBuf, size_t cbToWrite);
1059
1060 /**
1061 * Read bytes to the stream.
1062 *
1063 * @returns VBox status code.
1064 * @param pvUser The user argument.
1065 * @param offStream The stream offset we're (supposed to be) at.
1066 * @param pvBuf Where to return the bytes.
1067 * @param cbToRead The number of bytes to read.
1068 * @param pcbRead Where to return the number of bytes actually
1069 * read. This may differ from cbToRead when the
1070 * end of the stream is encountered.
1071 */
1072 DECLCALLBACKMEMBER(int, pfnRead)(void *pvUser, uint64_t offStream, void *pvBuf, size_t cbToRead, size_t *pcbRead);
1073
1074 /**
1075 * Seeks in the stream.
1076 *
1077 * @returns VBox status code.
1078 * @retval VERR_NOT_SUPPORTED if the stream doesn't support this action.
1079 *
1080 * @param pvUser The user argument.
1081 * @param offSeek The seek offset.
1082 * @param uMethod RTFILE_SEEK_BEGIN, RTFILE_SEEK_END or
1083 * RTFILE_SEEK_CURRENT.
1084 * @param poffActual Where to store the new file position. Optional.
1085 */
1086 DECLCALLBACKMEMBER(int, pfnSeek)(void *pvUser, int64_t offSeek, unsigned uMethod, uint64_t *poffActual);
1087
1088 /**
1089 * Get the current stream position.
1090 *
1091 * @returns The correct stream position.
1092 * @param pvUser The user argument.
1093 */
1094 DECLCALLBACKMEMBER(uint64_t, pfnTell)(void *pvUser);
1095
1096 /**
1097 * Get the size/length of the stream.
1098 *
1099 * @returns VBox status code.
1100 * @retval VERR_NOT_SUPPORTED if the stream doesn't support this action.
1101 *
1102 * @param pvUser The user argument.
1103 * @param pcb Where to return the size/length.
1104 */
1105 DECLCALLBACKMEMBER(int, pfnSize)(void *pvUser, uint64_t *pcb);
1106
1107 /**
1108 * Check if the stream is OK or not (cancelled).
1109 *
1110 * @returns VBox status code.
1111 * @param pvUser The user argument.
1112 *
1113 * @remarks The method is expected to do a LogRel on failure.
1114 */
1115 DECLCALLBACKMEMBER(int, pfnIsOk)(void *pvUser);
1116
1117 /**
1118 * Close the stream.
1119 *
1120 * @returns VBox status code.
1121 * @param pvUser The user argument.
1122 * @param fCancelled True if the operation was cancelled.
1123 */
1124 DECLCALLBACKMEMBER(int, pfnClose)(void *pvUser, bool fCancelled);
1125
1126 /** Struct magic + version (SSMSTRMOPS_VERSION). */
1127 uint32_t u32EndVersion;
1128} SSMSTRMOPS;
1129/** Struct magic + version (SSMSTRMOPS_VERSION). */
1130#define SSMSTRMOPS_VERSION UINT32_C(0x55aa0001)
1131
1132
1133VMMR3_INT_DECL(void) SSMR3Term(PVM pVM);
1134VMMR3DECL(int) SSMR3RegisterDevice(PVM pVM, PPDMDEVINS pDevIns, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess, const char *pszBefore,
1135 PFNSSMDEVLIVEPREP pfnLivePrep, PFNSSMDEVLIVEEXEC pfnLiveExec, PFNSSMDEVLIVEVOTE pfnLiveVote,
1136 PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
1137 PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone);
1138VMMR3DECL(int) SSMR3RegisterDriver(PVM pVM, PPDMDRVINS pDrvIns, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess,
1139 PFNSSMDRVLIVEPREP pfnLivePrep, PFNSSMDRVLIVEEXEC pfnLiveExec, PFNSSMDRVLIVEVOTE pfnLiveVote,
1140 PFNSSMDRVSAVEPREP pfnSavePrep, PFNSSMDRVSAVEEXEC pfnSaveExec, PFNSSMDRVSAVEDONE pfnSaveDone,
1141 PFNSSMDRVLOADPREP pfnLoadPrep, PFNSSMDRVLOADEXEC pfnLoadExec, PFNSSMDRVLOADDONE pfnLoadDone);
1142VMMR3DECL(int) SSMR3RegisterInternal(PVM pVM, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess,
1143 PFNSSMINTLIVEPREP pfnLivePrep, PFNSSMINTLIVEEXEC pfnLiveExec, PFNSSMINTLIVEVOTE pfnLiveVote,
1144 PFNSSMINTSAVEPREP pfnSavePrep, PFNSSMINTSAVEEXEC pfnSaveExec, PFNSSMINTSAVEDONE pfnSaveDone,
1145 PFNSSMINTLOADPREP pfnLoadPrep, PFNSSMINTLOADEXEC pfnLoadExec, PFNSSMINTLOADDONE pfnLoadDone);
1146VMMR3DECL(int) SSMR3RegisterExternal(PVM pVM, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess,
1147 PFNSSMEXTLIVEPREP pfnLivePrep, PFNSSMEXTLIVEEXEC pfnLiveExec, PFNSSMEXTLIVEVOTE pfnLiveVote,
1148 PFNSSMEXTSAVEPREP pfnSavePrep, PFNSSMEXTSAVEEXEC pfnSaveExec, PFNSSMEXTSAVEDONE pfnSaveDone,
1149 PFNSSMEXTLOADPREP pfnLoadPrep, PFNSSMEXTLOADEXEC pfnLoadExec, PFNSSMEXTLOADDONE pfnLoadDone, void *pvUser);
1150VMMR3_INT_DECL(int) SSMR3DeregisterDevice(PVM pVM, PPDMDEVINS pDevIns, const char *pszName, uint32_t uInstance);
1151VMMR3_INT_DECL(int) SSMR3DeregisterDriver(PVM pVM, PPDMDRVINS pDrvIns, const char *pszName, uint32_t uInstance);
1152VMMR3DECL(int) SSMR3DeregisterInternal(PVM pVM, const char *pszName);
1153VMMR3DECL(int) SSMR3DeregisterExternal(PVM pVM, const char *pszName);
1154VMMR3DECL(int) SSMR3Save(PVM pVM, const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser, SSMAFTER enmAfter, PFNVMPROGRESS pfnProgress, void *pvUser);
1155VMMR3_INT_DECL(int) SSMR3LiveSave(PVM pVM, uint32_t cMsMaxDowntime,
1156 const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvStreamOps,
1157 SSMAFTER enmAfter, PFNVMPROGRESS pfnProgress, void *pvProgressUser,
1158 PSSMHANDLE *ppSSM);
1159VMMR3_INT_DECL(int) SSMR3LiveDoStep1(PSSMHANDLE pSSM);
1160VMMR3_INT_DECL(int) SSMR3LiveDoStep2(PSSMHANDLE pSSM);
1161VMMR3_INT_DECL(int) SSMR3LiveDone(PSSMHANDLE pSSM);
1162VMMR3DECL(int) SSMR3Load(PVM pVM, const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser,
1163 SSMAFTER enmAfter, PFNVMPROGRESS pfnProgress, void *pvProgressUser);
1164VMMR3DECL(int) SSMR3ValidateFile(const char *pszFilename, bool fChecksumIt);
1165VMMR3DECL(int) SSMR3Open(const char *pszFilename, unsigned fFlags, PSSMHANDLE *ppSSM);
1166VMMR3DECL(int) SSMR3Close(PSSMHANDLE pSSM);
1167VMMR3DECL(int) SSMR3Seek(PSSMHANDLE pSSM, const char *pszUnit, uint32_t iInstance, uint32_t *piVersion);
1168VMMR3DECL(int) SSMR3HandleGetStatus(PSSMHANDLE pSSM);
1169VMMR3DECL(int) SSMR3HandleSetStatus(PSSMHANDLE pSSM, int iStatus);
1170VMMR3DECL(SSMAFTER) SSMR3HandleGetAfter(PSSMHANDLE pSSM);
1171VMMR3DECL(bool) SSMR3HandleIsLiveSave(PSSMHANDLE pSSM);
1172VMMR3DECL(uint32_t) SSMR3HandleMaxDowntime(PSSMHANDLE pSSM);
1173VMMR3DECL(uint32_t) SSMR3HandleHostBits(PSSMHANDLE pSSM);
1174VMMR3DECL(uint32_t) SSMR3HandleRevision(PSSMHANDLE pSSM);
1175VMMR3DECL(uint32_t) SSMR3HandleVersion(PSSMHANDLE pSSM);
1176VMMR3DECL(const char *) SSMR3HandleHostOSAndArch(PSSMHANDLE pSSM);
1177VMMR3_INT_DECL(int) SSMR3HandleSetGCPtrSize(PSSMHANDLE pSSM, unsigned cbGCPtr);
1178VMMR3DECL(void) SSMR3HandleReportLivePercent(PSSMHANDLE pSSM, unsigned uPercent);
1179VMMR3DECL(int) SSMR3Cancel(PVM pVM);
1180
1181
1182/** Save operations.
1183 * @{
1184 */
1185VMMR3DECL(int) SSMR3PutStruct(PSSMHANDLE pSSM, const void *pvStruct, PCSSMFIELD paFields);
1186VMMR3DECL(int) SSMR3PutStructEx(PSSMHANDLE pSSM, const void *pvStruct, size_t cbStruct, uint32_t fFlags, PCSSMFIELD paFields, void *pvUser);
1187VMMR3DECL(int) SSMR3PutBool(PSSMHANDLE pSSM, bool fBool);
1188VMMR3DECL(int) SSMR3PutU8(PSSMHANDLE pSSM, uint8_t u8);
1189VMMR3DECL(int) SSMR3PutS8(PSSMHANDLE pSSM, int8_t i8);
1190VMMR3DECL(int) SSMR3PutU16(PSSMHANDLE pSSM, uint16_t u16);
1191VMMR3DECL(int) SSMR3PutS16(PSSMHANDLE pSSM, int16_t i16);
1192VMMR3DECL(int) SSMR3PutU32(PSSMHANDLE pSSM, uint32_t u32);
1193VMMR3DECL(int) SSMR3PutS32(PSSMHANDLE pSSM, int32_t i32);
1194VMMR3DECL(int) SSMR3PutU64(PSSMHANDLE pSSM, uint64_t u64);
1195VMMR3DECL(int) SSMR3PutS64(PSSMHANDLE pSSM, int64_t i64);
1196VMMR3DECL(int) SSMR3PutU128(PSSMHANDLE pSSM, uint128_t u128);
1197VMMR3DECL(int) SSMR3PutS128(PSSMHANDLE pSSM, int128_t i128);
1198VMMR3DECL(int) SSMR3PutUInt(PSSMHANDLE pSSM, RTUINT u);
1199VMMR3DECL(int) SSMR3PutSInt(PSSMHANDLE pSSM, RTINT i);
1200VMMR3DECL(int) SSMR3PutGCUInt(PSSMHANDLE pSSM, RTGCUINT u);
1201VMMR3DECL(int) SSMR3PutGCUIntReg(PSSMHANDLE pSSM, RTGCUINTREG u);
1202VMMR3DECL(int) SSMR3PutGCPhys32(PSSMHANDLE pSSM, RTGCPHYS32 GCPhys);
1203VMMR3DECL(int) SSMR3PutGCPhys64(PSSMHANDLE pSSM, RTGCPHYS64 GCPhys);
1204VMMR3DECL(int) SSMR3PutGCPhys(PSSMHANDLE pSSM, RTGCPHYS GCPhys);
1205VMMR3DECL(int) SSMR3PutGCPtr(PSSMHANDLE pSSM, RTGCPTR GCPtr);
1206VMMR3DECL(int) SSMR3PutGCUIntPtr(PSSMHANDLE pSSM, RTGCUINTPTR GCPtr);
1207VMMR3DECL(int) SSMR3PutRCPtr(PSSMHANDLE pSSM, RTRCPTR RCPtr);
1208VMMR3DECL(int) SSMR3PutIOPort(PSSMHANDLE pSSM, RTIOPORT IOPort);
1209VMMR3DECL(int) SSMR3PutSel(PSSMHANDLE pSSM, RTSEL Sel);
1210VMMR3DECL(int) SSMR3PutMem(PSSMHANDLE pSSM, const void *pv, size_t cb);
1211VMMR3DECL(int) SSMR3PutStrZ(PSSMHANDLE pSSM, const char *psz);
1212/** @} */
1213
1214
1215
1216/** Load operations.
1217 * @{
1218 */
1219VMMR3DECL(int) SSMR3GetStruct(PSSMHANDLE pSSM, void *pvStruct, PCSSMFIELD paFields);
1220VMMR3DECL(int) SSMR3GetStructEx(PSSMHANDLE pSSM, void *pvStruct, size_t cbStruct, uint32_t fFlags, PCSSMFIELD paFields, void *pvUser);
1221VMMR3DECL(int) SSMR3GetBool(PSSMHANDLE pSSM, bool *pfBool);
1222VMMR3DECL(int) SSMR3GetU8(PSSMHANDLE pSSM, uint8_t *pu8);
1223VMMR3DECL(int) SSMR3GetS8(PSSMHANDLE pSSM, int8_t *pi8);
1224VMMR3DECL(int) SSMR3GetU16(PSSMHANDLE pSSM, uint16_t *pu16);
1225VMMR3DECL(int) SSMR3GetS16(PSSMHANDLE pSSM, int16_t *pi16);
1226VMMR3DECL(int) SSMR3GetU32(PSSMHANDLE pSSM, uint32_t *pu32);
1227VMMR3DECL(int) SSMR3GetS32(PSSMHANDLE pSSM, int32_t *pi32);
1228VMMR3DECL(int) SSMR3GetU64(PSSMHANDLE pSSM, uint64_t *pu64);
1229VMMR3DECL(int) SSMR3GetS64(PSSMHANDLE pSSM, int64_t *pi64);
1230VMMR3DECL(int) SSMR3GetU128(PSSMHANDLE pSSM, uint128_t *pu128);
1231VMMR3DECL(int) SSMR3GetS128(PSSMHANDLE pSSM, int128_t *pi128);
1232VMMR3DECL(int) SSMR3GetUInt(PSSMHANDLE pSSM, PRTUINT pu);
1233VMMR3DECL(int) SSMR3GetSInt(PSSMHANDLE pSSM, PRTINT pi);
1234VMMR3DECL(int) SSMR3GetGCUInt(PSSMHANDLE pSSM, PRTGCUINT pu);
1235VMMR3DECL(int) SSMR3GetGCUIntReg(PSSMHANDLE pSSM, PRTGCUINTREG pu);
1236VMMR3DECL(int) SSMR3GetGCPhys32(PSSMHANDLE pSSM, PRTGCPHYS32 pGCPhys);
1237VMMR3DECL(int) SSMR3GetGCPhys64(PSSMHANDLE pSSM, PRTGCPHYS64 pGCPhys);
1238VMMR3DECL(int) SSMR3GetGCPhys(PSSMHANDLE pSSM, PRTGCPHYS pGCPhys);
1239VMMR3DECL(int) SSMR3GetGCPtr(PSSMHANDLE pSSM, PRTGCPTR pGCPtr);
1240VMMR3DECL(int) SSMR3GetGCUIntPtr(PSSMHANDLE pSSM, PRTGCUINTPTR pGCPtr);
1241VMMR3DECL(int) SSMR3GetRCPtr(PSSMHANDLE pSSM, PRTRCPTR pRCPtr);
1242VMMR3DECL(int) SSMR3GetIOPort(PSSMHANDLE pSSM, PRTIOPORT pIOPort);
1243VMMR3DECL(int) SSMR3GetSel(PSSMHANDLE pSSM, PRTSEL pSel);
1244VMMR3DECL(int) SSMR3GetMem(PSSMHANDLE pSSM, void *pv, size_t cb);
1245VMMR3DECL(int) SSMR3GetStrZ(PSSMHANDLE pSSM, char *psz, size_t cbMax);
1246VMMR3DECL(int) SSMR3GetStrZEx(PSSMHANDLE pSSM, char *psz, size_t cbMax, size_t *pcbStr);
1247VMMR3DECL(int) SSMR3GetTimer(PSSMHANDLE pSSM, PTMTIMER pTimer);
1248VMMR3DECL(int) SSMR3Skip(PSSMHANDLE pSSM, size_t cb);
1249VMMR3DECL(int) SSMR3SkipToEndOfUnit(PSSMHANDLE pSSM);
1250VMMR3DECL(int) SSMR3SetLoadError(PSSMHANDLE pSSM, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...);
1251VMMR3DECL(int) SSMR3SetLoadErrorV(PSSMHANDLE pSSM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va);
1252VMMR3DECL(int) SSMR3SetCfgError(PSSMHANDLE pSSM, RT_SRC_POS_DECL, const char *pszFormat, ...);
1253
1254/** @} */
1255
1256/** @} */
1257#endif /* IN_RING3 */
1258
1259
1260/** @} */
1261
1262RT_C_DECLS_END
1263
1264#endif
1265
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