VirtualBox

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

Last change on this file since 104429 was 99922, checked in by vboxsync, 18 months ago

VMM/SSM: scm fix

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