VirtualBox

source: vbox/trunk/include/VBox/ssm.h@ 6287

Last change on this file since 6287 was 6287, checked in by vboxsync, 17 years ago

doxygen: Missing close.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 35.8 KB
Line 
1/** @file
2 * SSM - The Save State Manager.
3 */
4
5/*
6 * Copyright (C) 2006-2007 innotek GmbH
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_ssm_h
27#define ___VBox_ssm_h
28
29#include <VBox/cdefs.h>
30#include <VBox/types.h>
31#include <VBox/tm.h>
32#include <VBox/vmapi.h>
33
34__BEGIN_DECLS
35
36/** @defgroup grp_ssm The Saved State Manager API
37 * @{
38 */
39
40#ifdef IN_RING3
41/** @defgroup grp_ssm_r3 The SSM Host Context Ring-3 API
42 * @{
43 */
44
45
46/**
47 * What to do after the save/load operation.
48 */
49typedef enum SSMAFTER
50{
51 /** Will resume the loaded state. */
52 SSMAFTER_RESUME = 1,
53 /** Will destroy the VM after saving. */
54 SSMAFTER_DESTROY,
55 /** Will continue execution after saving the VM. */
56 SSMAFTER_CONTINUE,
57 /** Will debug the saved state.
58 * This is used to drop some of the stricter consitentcy checks so it'll
59 * load fine in the debugger or animator. */
60 SSMAFTER_DEBUG_IT,
61 /** The file was opened using SSMR3Open() and we have no idea what the plan is. */
62 SSMAFTER_OPENED
63} SSMAFTER;
64
65
66/**
67 * A structure field description.
68 */
69typedef struct SSMFIELD
70{
71 /** Field offset into the structure. */
72 uint32_t off;
73 /** The size of the field. */
74 uint32_t cb;
75} SSMFIELD;
76/** Pointer to a structure field description. */
77typedef SSMFIELD *PSSMFIELD;
78/** Pointer to a const structure field description. */
79typedef const SSMFIELD *PCSSMFIELD;
80
81/** Emit a SSMFIELD array entry. */
82#define SSMFIELD_ENTRY(Type, Field) { RT_OFFSETOF(Type, Field), RT_SIZEOFMEMB(Type, Field) }
83/** Emit the terminating entry of a SSMFIELD array. */
84#define SSMFIELD_ENTRY_TERM() { UINT32_MAX, UINT32_MAX }
85
86
87
88/** The PDM Device callback variants.
89 * @{
90 */
91
92/**
93 * Prepare state save operation.
94 *
95 * @returns VBox status code.
96 * @param pDevIns Device instance of the device which registered the data unit.
97 * @param pSSM SSM operation handle.
98 */
99typedef DECLCALLBACK(int) FNSSMDEVSAVEPREP(PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
100/** Pointer to a FNSSMDEVSAVEPREP() function. */
101typedef FNSSMDEVSAVEPREP *PFNSSMDEVSAVEPREP;
102
103/**
104 * Execute state save operation.
105 *
106 * @returns VBox status code.
107 * @param pDevIns Device instance of the device which registered the data unit.
108 * @param pSSM SSM operation handle.
109 */
110typedef DECLCALLBACK(int) FNSSMDEVSAVEEXEC(PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
111/** Pointer to a FNSSMDEVSAVEEXEC() function. */
112typedef FNSSMDEVSAVEEXEC *PFNSSMDEVSAVEEXEC;
113
114/**
115 * Done state save operation.
116 *
117 * @returns VBox status code.
118 * @param pDevIns Device instance of the device which registered the data unit.
119 * @param pSSM SSM operation handle.
120 */
121typedef DECLCALLBACK(int) FNSSMDEVSAVEDONE(PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
122/** Pointer to a FNSSMDEVSAVEDONE() function. */
123typedef FNSSMDEVSAVEDONE *PFNSSMDEVSAVEDONE;
124
125/**
126 * Prepare state load operation.
127 *
128 * @returns VBox status code.
129 * @param pDevIns Device instance of the device which registered the data unit.
130 * @param pSSM SSM operation handle.
131 */
132typedef DECLCALLBACK(int) FNSSMDEVLOADPREP(PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
133/** Pointer to a FNSSMDEVLOADPREP() function. */
134typedef FNSSMDEVLOADPREP *PFNSSMDEVLOADPREP;
135
136/**
137 * Execute state load operation.
138 *
139 * @returns VBox status code.
140 * @param pDevIns Device instance of the device which registered the data unit.
141 * @param pSSM SSM operation handle.
142 * @param u32Version Data layout version.
143 */
144typedef DECLCALLBACK(int) FNSSMDEVLOADEXEC(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t u32Version);
145/** Pointer to a FNSSMDEVLOADEXEC() function. */
146typedef FNSSMDEVLOADEXEC *PFNSSMDEVLOADEXEC;
147
148/**
149 * Done state load operation.
150 *
151 * @returns VBox load code.
152 * @param pDevIns Device instance of the device which registered the data unit.
153 * @param pSSM SSM operation handle.
154 */
155typedef DECLCALLBACK(int) FNSSMDEVLOADDONE(PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
156/** Pointer to a FNSSMDEVLOADDONE() function. */
157typedef FNSSMDEVLOADDONE *PFNSSMDEVLOADDONE;
158
159/** @} */
160
161
162/** The PDM Driver callback variants.
163 * @{
164 */
165
166/**
167 * Prepare state save operation.
168 *
169 * @returns VBox status code.
170 * @param pDrvIns Driver instance of the driver which registered the data unit.
171 * @param pSSM SSM operation handle.
172 */
173typedef DECLCALLBACK(int) FNSSMDRVSAVEPREP(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM);
174/** Pointer to a FNSSMDRVSAVEPREP() function. */
175typedef FNSSMDRVSAVEPREP *PFNSSMDRVSAVEPREP;
176
177/**
178 * Execute state save operation.
179 *
180 * @returns VBox status code.
181 * @param pDrvIns Driver instance of the driver which registered the data unit.
182 * @param pSSM SSM operation handle.
183 */
184typedef DECLCALLBACK(int) FNSSMDRVSAVEEXEC(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM);
185/** Pointer to a FNSSMDRVSAVEEXEC() function. */
186typedef FNSSMDRVSAVEEXEC *PFNSSMDRVSAVEEXEC;
187
188/**
189 * Done state save operation.
190 *
191 * @returns VBox status code.
192 * @param pDrvIns Driver instance of the driver which registered the data unit.
193 * @param pSSM SSM operation handle.
194 */
195typedef DECLCALLBACK(int) FNSSMDRVSAVEDONE(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM);
196/** Pointer to a FNSSMDRVSAVEDONE() function. */
197typedef FNSSMDRVSAVEDONE *PFNSSMDRVSAVEDONE;
198
199/**
200 * Prepare state load operation.
201 *
202 * @returns VBox status code.
203 * @param pDrvIns Driver instance of the driver which registered the data unit.
204 * @param pSSM SSM operation handle.
205 */
206typedef DECLCALLBACK(int) FNSSMDRVLOADPREP(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM);
207/** Pointer to a FNSSMDRVLOADPREP() function. */
208typedef FNSSMDRVLOADPREP *PFNSSMDRVLOADPREP;
209
210/**
211 * Execute state load operation.
212 *
213 * @returns VBox status code.
214 * @param pDrvIns Driver instance of the driver which registered the data unit.
215 * @param pSSM SSM operation handle.
216 * @param u32Version Data layout version.
217 */
218typedef DECLCALLBACK(int) FNSSMDRVLOADEXEC(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM, uint32_t u32Version);
219/** Pointer to a FNSSMDRVLOADEXEC() function. */
220typedef FNSSMDRVLOADEXEC *PFNSSMDRVLOADEXEC;
221
222/**
223 * Done state load operation.
224 *
225 * @returns VBox load code.
226 * @param pDrvIns Driver instance of the driver which registered the data unit.
227 * @param pSSM SSM operation handle.
228 */
229typedef DECLCALLBACK(int) FNSSMDRVLOADDONE(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM);
230/** Pointer to a FNSSMDRVLOADDONE() function. */
231typedef FNSSMDRVLOADDONE *PFNSSMDRVLOADDONE;
232
233/** @} */
234
235
236/** The internal callback variants.
237 * @{
238 */
239
240/**
241 * Prepare state save operation.
242 *
243 * @returns VBox status code.
244 * @param pVM VM Handle.
245 * @param pSSM SSM operation handle.
246 */
247typedef DECLCALLBACK(int) FNSSMINTSAVEPREP(PVM pVM, PSSMHANDLE pSSM);
248/** Pointer to a FNSSMINTSAVEPREP() function. */
249typedef FNSSMINTSAVEPREP *PFNSSMINTSAVEPREP;
250
251/**
252 * Execute state save operation.
253 *
254 * @returns VBox status code.
255 * @param pVM VM Handle.
256 * @param pSSM SSM operation handle.
257 */
258typedef DECLCALLBACK(int) FNSSMINTSAVEEXEC(PVM pVM, PSSMHANDLE pSSM);
259/** Pointer to a FNSSMINTSAVEEXEC() function. */
260typedef FNSSMINTSAVEEXEC *PFNSSMINTSAVEEXEC;
261
262/**
263 * Done state save operation.
264 *
265 * @returns VBox status code.
266 * @param pVM VM Handle.
267 * @param pSSM SSM operation handle.
268 */
269typedef DECLCALLBACK(int) FNSSMINTSAVEDONE(PVM pVM, PSSMHANDLE pSSM);
270/** Pointer to a FNSSMINTSAVEDONE() function. */
271typedef FNSSMINTSAVEDONE *PFNSSMINTSAVEDONE;
272
273/**
274 * Prepare state load operation.
275 *
276 * @returns VBox status code.
277 * @param pVM VM Handle.
278 * @param pSSM SSM operation handle.
279 */
280typedef DECLCALLBACK(int) FNSSMINTLOADPREP(PVM pVM, PSSMHANDLE pSSM);
281/** Pointer to a FNSSMINTLOADPREP() function. */
282typedef FNSSMINTLOADPREP *PFNSSMINTLOADPREP;
283
284/**
285 * Execute state load operation.
286 *
287 * @returns VBox status code.
288 * @param pVM VM Handle.
289 * @param pSSM SSM operation handle.
290 * @param u32Version Data layout version.
291 */
292typedef DECLCALLBACK(int) FNSSMINTLOADEXEC(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version);
293/** Pointer to a FNSSMINTLOADEXEC() function. */
294typedef FNSSMINTLOADEXEC *PFNSSMINTLOADEXEC;
295
296/**
297 * Done state load operation.
298 *
299 * @returns VBox load code.
300 * @param pVM VM Handle.
301 * @param pSSM SSM operation handle.
302 */
303typedef DECLCALLBACK(int) FNSSMINTLOADDONE(PVM pVM, PSSMHANDLE pSSM);
304/** Pointer to a FNSSMINTLOADDONE() function. */
305typedef FNSSMINTLOADDONE *PFNSSMINTLOADDONE;
306
307/** @} */
308
309
310/** The External callback variants.
311 * @{
312 */
313
314/**
315 * Prepare state save operation.
316 *
317 * @returns VBox status code.
318 * @param pSSM SSM operation handle.
319 * @param pvUser User argument.
320 */
321typedef DECLCALLBACK(int) FNSSMEXTSAVEPREP(PSSMHANDLE pSSM, void *pvUser);
322/** Pointer to a FNSSMEXTSAVEPREP() function. */
323typedef FNSSMEXTSAVEPREP *PFNSSMEXTSAVEPREP;
324
325/**
326 * Execute state save operation.
327 *
328 * @param pSSM SSM operation handle.
329 * @param pvUser User argument.
330 * @author The lack of return code is for legacy reasons.
331 */
332typedef DECLCALLBACK(void) FNSSMEXTSAVEEXEC(PSSMHANDLE pSSM, void *pvUser);
333/** Pointer to a FNSSMEXTSAVEEXEC() function. */
334typedef FNSSMEXTSAVEEXEC *PFNSSMEXTSAVEEXEC;
335
336/**
337 * Done state save operation.
338 *
339 * @returns VBox status code.
340 * @param pSSM SSM operation handle.
341 * @param pvUser User argument.
342 */
343typedef DECLCALLBACK(int) FNSSMEXTSAVEDONE(PSSMHANDLE pSSM, void *pvUser);
344/** Pointer to a FNSSMEXTSAVEDONE() function. */
345typedef FNSSMEXTSAVEDONE *PFNSSMEXTSAVEDONE;
346
347/**
348 * Prepare state load operation.
349 *
350 * @returns VBox status code.
351 * @param pSSM SSM operation handle.
352 * @param pvUser User argument.
353 */
354typedef DECLCALLBACK(int) FNSSMEXTLOADPREP(PSSMHANDLE pSSM, void *pvUser);
355/** Pointer to a FNSSMEXTLOADPREP() function. */
356typedef FNSSMEXTLOADPREP *PFNSSMEXTLOADPREP;
357
358/**
359 * Execute state load operation.
360 *
361 * @returns 0 on success.
362 * @returns Not 0 on failure.
363 * @param pSSM SSM operation handle.
364 * @param pvUser User argument.
365 * @param u32Version Data layout version.
366 * @remark The odd return value is for legacy reasons.
367 */
368typedef DECLCALLBACK(int) FNSSMEXTLOADEXEC(PSSMHANDLE pSSM, void *pvUser, uint32_t u32Version);
369/** Pointer to a FNSSMEXTLOADEXEC() function. */
370typedef FNSSMEXTLOADEXEC *PFNSSMEXTLOADEXEC;
371
372/**
373 * Done state load operation.
374 *
375 * @returns VBox load code.
376 * @param pSSM SSM operation handle.
377 * @param pvUser User argument.
378 */
379typedef DECLCALLBACK(int) FNSSMEXTLOADDONE(PSSMHANDLE pSSM, void *pvUser);
380/** Pointer to a FNSSMEXTLOADDONE() function. */
381typedef FNSSMEXTLOADDONE *PFNSSMEXTLOADDONE;
382
383/** @} */
384
385
386
387/**
388 * Register a PDM Devices data unit.
389 *
390 * @returns VBox status.
391 * @param pVM The VM handle.
392 * @param pDevIns Device instance.
393 * @param pszName Data unit name.
394 * @param u32Instance The instance identifier of the data unit.
395 * This must together with the name be unique.
396 * @param u32Version Data layout version number.
397 * @param cbGuess The approximate amount of data in the unit.
398 * Only for progress indicators.
399 * @param pfnSavePrep Prepare save callback, optional.
400 * @param pfnSaveExec Execute save callback, optional.
401 * @param pfnSaveDone Done save callback, optional.
402 * @param pfnLoadPrep Prepare load callback, optional.
403 * @param pfnLoadExec Execute load callback, optional.
404 * @param pfnLoadDone Done load callback, optional.
405 */
406SSMR3DECL(int) SSMR3Register(PVM pVM, PPDMDEVINS pDevIns, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess,
407 PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
408 PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone);
409
410/**
411 * Register a PDM driver data unit.
412 *
413 * @returns VBox status.
414 * @param pVM The VM handle.
415 * @param pDrvIns Driver instance.
416 * @param pszName Data unit name.
417 * @param u32Instance The instance identifier of the data unit.
418 * This must together with the name be unique.
419 * @param u32Version Data layout version number.
420 * @param cbGuess The approximate amount of data in the unit.
421 * Only for progress indicators.
422 * @param pfnSavePrep Prepare save callback, optional.
423 * @param pfnSaveExec Execute save callback, optional.
424 * @param pfnSaveDone Done save callback, optional.
425 * @param pfnLoadPrep Prepare load callback, optional.
426 * @param pfnLoadExec Execute load callback, optional.
427 * @param pfnLoadDone Done load callback, optional.
428 */
429SSMR3DECL(int) SSMR3RegisterDriver(PVM pVM, PPDMDRVINS pDrvIns, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess,
430 PFNSSMDRVSAVEPREP pfnSavePrep, PFNSSMDRVSAVEEXEC pfnSaveExec, PFNSSMDRVSAVEDONE pfnSaveDone,
431 PFNSSMDRVLOADPREP pfnLoadPrep, PFNSSMDRVLOADEXEC pfnLoadExec, PFNSSMDRVLOADDONE pfnLoadDone);
432
433/**
434 * Register a internal data unit.
435 *
436 * @returns VBox status.
437 * @param pVM The VM handle.
438 * @param pszName Data unit name.
439 * @param u32Instance The instance identifier of the data unit.
440 * This must together with the name be unique.
441 * @param u32Version Data layout version number.
442 * @param cbGuess The approximate amount of data in the unit.
443 * Only for progress indicators.
444 * @param pfnSavePrep Prepare save callback, optional.
445 * @param pfnSaveExec Execute save callback, optional.
446 * @param pfnSaveDone Done save callback, optional.
447 * @param pfnLoadPrep Prepare load callback, optional.
448 * @param pfnLoadExec Execute load callback, optional.
449 * @param pfnLoadDone Done load callback, optional.
450 */
451SSMR3DECL(int) SSMR3RegisterInternal(PVM pVM, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess,
452 PFNSSMINTSAVEPREP pfnSavePrep, PFNSSMINTSAVEEXEC pfnSaveExec, PFNSSMINTSAVEDONE pfnSaveDone,
453 PFNSSMINTLOADPREP pfnLoadPrep, PFNSSMINTLOADEXEC pfnLoadExec, PFNSSMINTLOADDONE pfnLoadDone);
454
455/**
456 * Register a unit.
457 *
458 * @returns VBox status.
459 * @param pVM The VM handle.
460 * @param pszName Data unit name.
461 * @param u32Instance The instance identifier of the data unit.
462 * This must together with the name be unique.
463 * @param u32Version Data layout version number.
464 * @param cbGuess The approximate amount of data in the unit.
465 * Only for progress indicators.
466 * @param pfnSavePrep Prepare save callback, optional.
467 * @param pfnSaveExec Execute save callback, optional.
468 * @param pfnSaveDone Done save callback, optional.
469 * @param pfnLoadPrep Prepare load callback, optional.
470 * @param pfnLoadExec Execute load callback, optional.
471 * @param pfnLoadDone Done load callback, optional.
472 * @param pvUser User argument.
473 */
474SSMR3DECL(int) SSMR3RegisterExternal(PVM pVM, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess,
475 PFNSSMEXTSAVEPREP pfnSavePrep, PFNSSMEXTSAVEEXEC pfnSaveExec, PFNSSMEXTSAVEDONE pfnSaveDone,
476 PFNSSMEXTLOADPREP pfnLoadPrep, PFNSSMEXTLOADEXEC pfnLoadExec, PFNSSMEXTLOADDONE pfnLoadDone, void *pvUser);
477
478/**
479 * Deregister one or more PDM Device data units.
480 *
481 * @returns VBox status.
482 * @param pVM The VM handle.
483 * @param pDevIns Device instance.
484 * @param pszName Data unit name.
485 * Use NULL to deregister all data units for that device instance.
486 * @param u32Instance The instance identifier of the data unit.
487 * This must together with the name be unique. Ignored if pszName is NULL.
488 * @remark Only for dynmaic data units and dynamic unloaded modules.
489 */
490SSMR3DECL(int) SSMR3Deregister(PVM pVM, PPDMDEVINS pDevIns, const char *pszName, uint32_t u32Instance);
491
492/**
493 * Deregister one or more PDM Driver data units.
494 *
495 * @returns VBox status.
496 * @param pVM The VM handle.
497 * @param pDrvIns Driver instance.
498 * @param pszName Data unit name.
499 * Use NULL to deregister all data units for that driver instance.
500 * @param u32Instance The instance identifier of the data unit.
501 * This must together with the name be unique. Ignored if pszName is NULL.
502 * @remark Only for dynmaic data units and dynamic unloaded modules.
503 */
504SSMR3DECL(int) SSMR3DeregisterDriver(PVM pVM, PPDMDRVINS pDrvIns, const char *pszName, uint32_t u32Instance);
505
506/**
507 * Deregister a internal data unit.
508 *
509 * @returns VBox status.
510 * @param pVM The VM handle.
511 * @param pszName Data unit name.
512 * @remark Only for dynmaic data units.
513 */
514SSMR3DECL(int) SSMR3DeregisterInternal(PVM pVM, const char *pszName);
515
516/**
517 * Deregister an external data unit.
518 *
519 * @returns VBox status.
520 * @param pVM The VM handle.
521 * @param pszName Data unit name.
522 * @remark Only for dynmaic data units.
523 */
524SSMR3DECL(int) SSMR3DeregisterExternal(PVM pVM, const char *pszName);
525
526/**
527 * Start VM save operation.
528 *
529 * The caller must be the emulation thread!
530 *
531 * @returns VBox status.
532 * @param pVM The VM handle.
533 * @param pszFilename Name of the file to save the state in.
534 * @param enmAfter What is planned after a successful save operation.
535 * @param pfnProgress Progress callback. Optional.
536 * @param pvUser User argument for the progress callback.
537 */
538SSMR3DECL(int) SSMR3Save(PVM pVM, const char *pszFilename, SSMAFTER enmAfter, PFNVMPROGRESS pfnProgress, void *pvUser);
539
540/**
541 * Load VM save operation.
542 *
543 * The caller must be the emulation thread!
544 *
545 * @returns VBox status.
546 * @param pVM The VM handle.
547 * @param pszFilename Name of the file to save the state in.
548 * @param enmAfter What is planned after a successful load operation.
549 * Only acceptable values are SSMAFTER_RESUME and SSMAFTER_DEBUG_IT.
550 * @param pfnProgress Progress callback. Optional.
551 * @param pvUser User argument for the progress callback.
552 */
553SSMR3DECL(int) SSMR3Load(PVM pVM, const char *pszFilename, SSMAFTER enmAfter, PFNVMPROGRESS pfnProgress, void *pvUser);
554
555/**
556 * Validates a file as a validate SSM saved state.
557 *
558 * This will only verify the file format, the format and content of individual
559 * data units are not inspected.
560 *
561 * @returns VINF_SUCCESS if valid.
562 * @returns VBox status code on other failures.
563 * @param pszFilename The path to the file to validate.
564 */
565SSMR3DECL(int) SSMR3ValidateFile(const char *pszFilename);
566
567/**
568 * Opens a saved state file for reading.
569 *
570 * @returns VBox status code.
571 * @param pszFilename The path to the saved state file.
572 * @param fFlags Open flags. Reserved, must be 0.
573 * @param ppSSM Where to store the SSM handle.
574 */
575SSMR3DECL(int) SSMR3Open(const char *pszFilename, unsigned fFlags, PSSMHANDLE *ppSSM);
576
577/**
578 * Closes a saved state file opened by SSMR3Open().
579 *
580 * @returns VBox status code.
581 * @param pSSM The SSM handle returned by SSMR3Open().
582 */
583SSMR3DECL(int) SSMR3Close(PSSMHANDLE pSSM);
584
585/**
586 * Seeks to a specific data unit.
587 *
588 * After seeking it's possible to use the getters to on
589 * that data unit.
590 *
591 * @returns VBox status code.
592 * @returns VERR_SSM_UNIT_NOT_FOUND if the unit+instance wasn't found.
593 * @param pSSM The SSM handle returned by SSMR3Open().
594 * @param pszUnit The name of the data unit.
595 * @param iInstance The instance number.
596 * @param piVersion Where to store the version number. (Optional)
597 */
598SSMR3DECL(int) SSMR3Seek(PSSMHANDLE pSSM, const char *pszUnit, uint32_t iInstance, uint32_t *piVersion);
599
600
601/** Save operations.
602 * @{
603 */
604
605/**
606 * Puts a structure.
607 *
608 * @returns VBox status code.
609 * @param pSSM The saved state handle.
610 * @param pvStruct The structure address.
611 * @param paFields The array of structure fields descriptions.
612 * The array must be terminated by a SSMFIELD_ENTRY_TERM().
613 */
614SSMR3DECL(int) SSMR3PutStruct(PSSMHANDLE pSSM, const void *pvStruct, PCSSMFIELD paFields);
615
616/**
617 * Saves a boolean item to the current data unit.
618 *
619 * @returns VBox status.
620 * @param pSSM SSM operation handle.
621 * @param fBool Item to save.
622 */
623SSMR3DECL(int) SSMR3PutBool(PSSMHANDLE pSSM, bool fBool);
624
625/**
626 * Saves a 8-bit unsigned integer item to the current data unit.
627 *
628 * @returns VBox status.
629 * @param pSSM SSM operation handle.
630 * @param u8 Item to save.
631 */
632SSMR3DECL(int) SSMR3PutU8(PSSMHANDLE pSSM, uint8_t u8);
633
634/**
635 * Saves a 8-bit signed integer item to the current data unit.
636 *
637 * @returns VBox status.
638 * @param pSSM SSM operation handle.
639 * @param i8 Item to save.
640 */
641SSMR3DECL(int) SSMR3PutS8(PSSMHANDLE pSSM, int8_t i8);
642
643/**
644 * Saves a 16-bit unsigned integer item to the current data unit.
645 *
646 * @returns VBox status.
647 * @param pSSM SSM operation handle.
648 * @param u16 Item to save.
649 */
650SSMR3DECL(int) SSMR3PutU16(PSSMHANDLE pSSM, uint16_t u16);
651
652/**
653 * Saves a 16-bit signed integer item to the current data unit.
654 *
655 * @returns VBox status.
656 * @param pSSM SSM operation handle.
657 * @param i16 Item to save.
658 */
659SSMR3DECL(int) SSMR3PutS16(PSSMHANDLE pSSM, int16_t i16);
660
661/**
662 * Saves a 32-bit unsigned integer item to the current data unit.
663 *
664 * @returns VBox status.
665 * @param pSSM SSM operation handle.
666 * @param u32 Item to save.
667 */
668SSMR3DECL(int) SSMR3PutU32(PSSMHANDLE pSSM, uint32_t u32);
669
670/**
671 * Saves a 32-bit signed integer item to the current data unit.
672 *
673 * @returns VBox status.
674 * @param pSSM SSM operation handle.
675 * @param i32 Item to save.
676 */
677SSMR3DECL(int) SSMR3PutS32(PSSMHANDLE pSSM, int32_t i32);
678
679/**
680 * Saves a 64-bit unsigned integer item to the current data unit.
681 *
682 * @returns VBox status.
683 * @param pSSM SSM operation handle.
684 * @param u64 Item to save.
685 */
686SSMR3DECL(int) SSMR3PutU64(PSSMHANDLE pSSM, uint64_t u64);
687
688/**
689 * Saves a 64-bit signed integer item to the current data unit.
690 *
691 * @returns VBox status.
692 * @param pSSM SSM operation handle.
693 * @param i64 Item to save.
694 */
695SSMR3DECL(int) SSMR3PutS64(PSSMHANDLE pSSM, int64_t i64);
696
697/**
698 * Saves a 128-bit unsigned integer item to the current data unit.
699 *
700 * @returns VBox status.
701 * @param pSSM SSM operation handle.
702 * @param u128 Item to save.
703 */
704SSMR3DECL(int) SSMR3PutU128(PSSMHANDLE pSSM, uint128_t u128);
705
706/**
707 * Saves a 128-bit signed integer item to the current data unit.
708 *
709 * @returns VBox status.
710 * @param pSSM SSM operation handle.
711 * @param i128 Item to save.
712 */
713SSMR3DECL(int) SSMR3PutS128(PSSMHANDLE pSSM, int128_t i128);
714
715/**
716 * Saves a VBox unsigned integer item to the current data unit.
717 *
718 * @returns VBox status.
719 * @param pSSM SSM operation handle.
720 * @param u Item to save.
721 */
722SSMR3DECL(int) SSMR3PutUInt(PSSMHANDLE pSSM, RTUINT u);
723
724/**
725 * Saves a VBox signed integer item to the current data unit.
726 *
727 * @returns VBox status.
728 * @param pSSM SSM operation handle.
729 * @param i Item to save.
730 */
731SSMR3DECL(int) SSMR3PutSInt(PSSMHANDLE pSSM, RTINT i);
732
733/**
734 * Saves a GC natural unsigned integer item to the current data unit.
735 *
736 * @returns VBox status.
737 * @param pSSM SSM operation handle.
738 * @param u Item to save.
739 */
740SSMR3DECL(int) SSMR3PutGCUInt(PSSMHANDLE pSSM, RTGCUINT u);
741
742/**
743 * Saves a GC natural signed integer item to the current data unit.
744 *
745 * @returns VBox status.
746 * @param pSSM SSM operation handle.
747 * @param i Item to save.
748 */
749SSMR3DECL(int) SSMR3PutGCSInt(PSSMHANDLE pSSM, RTGCINT i);
750
751/**
752 * Saves a GC physical address item to the current data unit.
753 *
754 * @returns VBox status.
755 * @param pSSM SSM operation handle.
756 * @param GCPhys The item to save
757 */
758SSMR3DECL(int) SSMR3PutGCPhys(PSSMHANDLE pSSM, RTGCPHYS GCPhys);
759
760/**
761 * Saves a GC virtual address item to the current data unit.
762 *
763 * @returns VBox status.
764 * @param pSSM SSM operation handle.
765 * @param GCPtr The item to save.
766 */
767SSMR3DECL(int) SSMR3PutGCPtr(PSSMHANDLE pSSM, RTGCPTR GCPtr);
768
769/**
770 * Saves a GC virtual address (represented as an unsigned integer) item to the current data unit.
771 *
772 * @returns VBox status.
773 * @param pSSM SSM operation handle.
774 * @param GCPtr The item to save.
775 */
776SSMR3DECL(int) SSMR3PutGCUIntPtr(PSSMHANDLE pSSM, RTGCUINTPTR GCPtr);
777
778/**
779 * Saves a HC natural unsigned integer item to the current data unit.
780 *
781 * @returns VBox status.
782 * @param pSSM SSM operation handle.
783 * @param u Item to save.
784 */
785SSMR3DECL(int) SSMR3PutHCUInt(PSSMHANDLE pSSM, RTHCUINT u);
786
787/**
788 * Saves a HC natural signed integer item to the current data unit.
789 *
790 * @returns VBox status.
791 * @param pSSM SSM operation handle.
792 * @param i Item to save.
793 */
794SSMR3DECL(int) SSMR3PutHCSInt(PSSMHANDLE pSSM, RTHCINT i);
795
796/**
797 * Saves a I/O port address item to the current data unit.
798 *
799 * @returns VBox status.
800 * @param pSSM SSM operation handle.
801 * @param IOPort The item to save.
802 */
803SSMR3DECL(int) SSMR3PutIOPort(PSSMHANDLE pSSM, RTIOPORT IOPort);
804
805/**
806 * Saves a selector item to the current data unit.
807 *
808 * @returns VBox status.
809 * @param pSSM SSM operation handle.
810 * @param Sel The item to save.
811 */
812SSMR3DECL(int) SSMR3PutSel(PSSMHANDLE pSSM, RTSEL Sel);
813
814/**
815 * Saves a memory item to the current data unit.
816 *
817 * @returns VBox status.
818 * @param pSSM SSM operation handle.
819 * @param pv Item to save.
820 * @param cb Size of the item.
821 */
822SSMR3DECL(int) SSMR3PutMem(PSSMHANDLE pSSM, const void *pv, size_t cb);
823
824/**
825 * Saves a zero terminated string item to the current data unit.
826 *
827 * @returns VBox status.
828 * @param pSSM SSM operation handle.
829 * @param psz Item to save.
830 */
831SSMR3DECL(int) SSMR3PutStrZ(PSSMHANDLE pSSM, const char *psz);
832
833/** @} */
834
835
836
837/** Load operations.
838 * @{
839 */
840
841/**
842 * Gets a structure.
843 *
844 * @returns VBox status code.
845 * @param pSSM The saved state handle.
846 * @param pvStruct The structure address.
847 * @param paFields The array of structure fields descriptions.
848 * The array must be terminated by a SSMFIELD_ENTRY_TERM().
849 */
850SSMR3DECL(int) SSMR3GetStruct(PSSMHANDLE pSSM, void *pvStruct, PCSSMFIELD paFields);
851
852/**
853 * Loads a boolean item from the current data unit.
854 *
855 * @returns VBox status.
856 * @param pSSM SSM operation handle.
857 * @param pfBool Where to store the item.
858 */
859SSMR3DECL(int) SSMR3GetBool(PSSMHANDLE pSSM, bool *pfBool);
860
861/**
862 * Loads a 8-bit unsigned integer item from the current data unit.
863 *
864 * @returns VBox status.
865 * @param pSSM SSM operation handle.
866 * @param pu8 Where to store the item.
867 */
868SSMR3DECL(int) SSMR3GetU8(PSSMHANDLE pSSM, uint8_t *pu8);
869
870/**
871 * Loads a 8-bit signed integer item from the current data unit.
872 *
873 * @returns VBox status.
874 * @param pSSM SSM operation handle.
875 * @param pi8 Where to store the item.
876 */
877SSMR3DECL(int) SSMR3GetS8(PSSMHANDLE pSSM, int8_t *pi8);
878
879/**
880 * Loads a 16-bit unsigned integer item from the current data unit.
881 *
882 * @returns VBox status.
883 * @param pSSM SSM operation handle.
884 * @param pu16 Where to store the item.
885 */
886SSMR3DECL(int) SSMR3GetU16(PSSMHANDLE pSSM, uint16_t *pu16);
887
888/**
889 * Loads a 16-bit signed integer item from the current data unit.
890 *
891 * @returns VBox status.
892 * @param pSSM SSM operation handle.
893 * @param pi16 Where to store the item.
894 */
895SSMR3DECL(int) SSMR3GetS16(PSSMHANDLE pSSM, int16_t *pi16);
896
897/**
898 * Loads a 32-bit unsigned integer item from the current data unit.
899 *
900 * @returns VBox status.
901 * @param pSSM SSM operation handle.
902 * @param pu32 Where to store the item.
903 */
904SSMR3DECL(int) SSMR3GetU32(PSSMHANDLE pSSM, uint32_t *pu32);
905
906/**
907 * Loads a 32-bit signed integer item from the current data unit.
908 *
909 * @returns VBox status.
910 * @param pSSM SSM operation handle.
911 * @param pi32 Where to store the item.
912 */
913SSMR3DECL(int) SSMR3GetS32(PSSMHANDLE pSSM, int32_t *pi32);
914
915/**
916 * Loads a 64-bit unsigned integer item from the current data unit.
917 *
918 * @returns VBox status.
919 * @param pSSM SSM operation handle.
920 * @param pu64 Where to store the item.
921 */
922SSMR3DECL(int) SSMR3GetU64(PSSMHANDLE pSSM, uint64_t *pu64);
923
924/**
925 * Loads a 64-bit signed integer item from the current data unit.
926 *
927 * @returns VBox status.
928 * @param pSSM SSM operation handle.
929 * @param pi64 Where to store the item.
930 */
931SSMR3DECL(int) SSMR3GetS64(PSSMHANDLE pSSM, int64_t *pi64);
932
933/**
934 * Loads a 128-bit unsigned integer item from the current data unit.
935 *
936 * @returns VBox status.
937 * @param pSSM SSM operation handle.
938 * @param pu128 Where to store the item.
939 */
940SSMR3DECL(int) SSMR3GetU128(PSSMHANDLE pSSM, uint128_t *pu128);
941
942/**
943 * Loads a 128-bit signed integer item from the current data unit.
944 *
945 * @returns VBox status.
946 * @param pSSM SSM operation handle.
947 * @param pi128 Where to store the item.
948 */
949SSMR3DECL(int) SSMR3GetS128(PSSMHANDLE pSSM, int128_t *pi128);
950
951/**
952 * Loads a VBox unsigned integer item from the current data unit.
953 *
954 * @returns VBox status.
955 * @param pSSM SSM operation handle.
956 * @param pu Where to store the integer.
957 */
958SSMR3DECL(int) SSMR3GetUInt(PSSMHANDLE pSSM, PRTUINT pu);
959
960/**
961 * Loads a VBox signed integer item from the current data unit.
962 *
963 * @returns VBox status.
964 * @param pSSM SSM operation handle.
965 * @param pi Where to store the integer.
966 */
967SSMR3DECL(int) SSMR3GetSInt(PSSMHANDLE pSSM, PRTINT pi);
968
969/**
970 * Loads a GC natural unsigned integer item from the current data unit.
971 *
972 * @returns VBox status.
973 * @param pSSM SSM operation handle.
974 * @param pu Where to store the integer.
975 */
976SSMR3DECL(int) SSMR3GetGCUInt(PSSMHANDLE pSSM, PRTGCUINT pu);
977
978/**
979 * Loads a GC natural signed integer item from the current data unit.
980 *
981 * @returns VBox status.
982 * @param pSSM SSM operation handle.
983 * @param pi Where to store the integer.
984 */
985SSMR3DECL(int) SSMR3GetGCSInt(PSSMHANDLE pSSM, PRTGCINT pi);
986
987/**
988 * Loads a GC physical address item from the current data unit.
989 *
990 * @returns VBox status.
991 * @param pSSM SSM operation handle.
992 * @param pGCPhys Where to store the GC physical address.
993 */
994SSMR3DECL(int) SSMR3GetGCPhys(PSSMHANDLE pSSM, PRTGCPHYS pGCPhys);
995
996/**
997 * Loads a GC virtual address item from the current data unit.
998 *
999 * @returns VBox status.
1000 * @param pSSM SSM operation handle.
1001 * @param pGCPtr Where to store the GC virtual address.
1002 */
1003SSMR3DECL(int) SSMR3GetGCPtr(PSSMHANDLE pSSM, PRTGCPTR pGCPtr);
1004
1005/**
1006 * Loads a GC virtual address (represented as unsigned integer) item from the current data unit.
1007 *
1008 * @returns VBox status.
1009 * @param pSSM SSM operation handle.
1010 * @param pGCPtr Where to store the GC virtual address.
1011 */
1012SSMR3DECL(int) SSMR3GetGCUIntPtr(PSSMHANDLE pSSM, PRTGCUINTPTR pGCPtr);
1013
1014/**
1015 * Loads a I/O port address item from the current data unit.
1016 *
1017 * @returns VBox status.
1018 * @param pSSM SSM operation handle.
1019 * @param pIOPort Where to store the I/O port address.
1020 */
1021SSMR3DECL(int) SSMR3GetIOPort(PSSMHANDLE pSSM, PRTIOPORT pIOPort);
1022
1023/**
1024 * Loads a HC natural unsigned integer item from the current data unit.
1025 *
1026 * @returns VBox status.
1027 * @param pSSM SSM operation handle.
1028 * @param pu Where to store the integer.
1029 */
1030SSMR3DECL(int) SSMR3GetHCUInt(PSSMHANDLE pSSM, PRTHCUINT pu);
1031
1032/**
1033 * Loads a HC natural signed integer item from the current data unit.
1034 *
1035 * @returns VBox status.
1036 * @param pSSM SSM operation handle.
1037 * @param pi Where to store the integer.
1038 */
1039SSMR3DECL(int) SSMR3GetHCSInt(PSSMHANDLE pSSM, PRTHCINT pi);
1040
1041/**
1042 * Loads a selector item from the current data unit.
1043 *
1044 * @returns VBox status.
1045 * @param pSSM SSM operation handle.
1046 * @param pSel Where to store the selector.
1047 */
1048SSMR3DECL(int) SSMR3GetSel(PSSMHANDLE pSSM, PRTSEL pSel);
1049
1050/**
1051 * Loads a memory item from the current data unit.
1052 *
1053 * @returns VBox status.
1054 * @param pSSM SSM operation handle.
1055 * @param pv Where to store the item.
1056 * @param cb Size of the item.
1057 */
1058SSMR3DECL(int) SSMR3GetMem(PSSMHANDLE pSSM, void *pv, size_t cb);
1059
1060/**
1061 * Loads a string item from the current data unit.
1062 *
1063 * @returns VBox status.
1064 * @param pSSM SSM operation handle.
1065 * @param psz Where to store the item.
1066 * @param cbMax Max size of the item (including '\\0').
1067 */
1068SSMR3DECL(int) SSMR3GetStrZ(PSSMHANDLE pSSM, char *psz, size_t cbMax);
1069
1070/**
1071 * Loads a string item from the current data unit.
1072 *
1073 * @returns VBox status.
1074 * @param pSSM SSM operation handle.
1075 * @param psz Where to store the item.
1076 * @param cbMax Max size of the item (including '\\0').
1077 * @param pcbStr The length of the loaded string excluding the '\\0'. (optional)
1078 */
1079SSMR3DECL(int) SSMR3GetStrZEx(PSSMHANDLE pSSM, char *psz, size_t cbMax, size_t *pcbStr);
1080
1081/**
1082 * Loads a timer item from the current data unit.
1083 *
1084 * @returns VBox status.
1085 * @param pSSM SSM operation handle.
1086 * @param PTMTIMER Where to store the item.
1087 */
1088SSMR3DECL(int) SSMR3GetTimer(PSSMHANDLE pSSM, PTMTIMER pTimer);
1089
1090/** @} */
1091
1092
1093
1094/**
1095 * Query what the VBox status code of the operation is.
1096 *
1097 * This can be used for putting and getting a batch of values
1098 * without bother checking the result till all the calls have
1099 * been made.
1100 *
1101 * @returns VBox status code.
1102 * @param pSSM SSM operation handle.
1103 */
1104SSMR3DECL(int) SSMR3HandleGetStatus(PSSMHANDLE pSSM);
1105
1106/**
1107 * Fail the load operation.
1108 *
1109 * This is mainly intended for sub item loaders (like timers) which
1110 * return code isn't necessarily heeded by the caller but is important
1111 * to SSM.
1112 *
1113 * @returns SSMAFTER enum value.
1114 * @param pSSM SSM operation handle.
1115 * @param iStatus Failure status code. This MUST be a VERR_*.
1116 */
1117SSMR3DECL(int) SSMR3HandleSetStatus(PSSMHANDLE pSSM, int iStatus);
1118
1119/**
1120 * Query what to do after this operation.
1121 *
1122 * @returns SSMAFTER enum value.
1123 * @param pSSM SSM operation handle.
1124 */
1125SSMR3DECL(SSMAFTER) SSMR3HandleGetAfter(PSSMHANDLE pSSM);
1126
1127/** @} */
1128#endif /* IN_RING3 */
1129
1130
1131/** @} */
1132
1133__END_DECLS
1134
1135#endif
1136
Note: See TracBrowser for help on using the repository browser.

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