VirtualBox

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

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

Fixed x86/amd64 file header difference. Added SSMAFTER_DEBUG_IT for tstAnimate and (later) debugger usage.

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