Restore a Snapshot (Compact 2013)

3/26/2014

To boot from a snapshot, you first need a way to determine that a snapshot exists on the device. Then you must provide the implementation of the APIs that are used to restore the snapshot image, decompress the snapshot if necessary, reinitialize device hardware, and resume the system.

You can decrease the time that is required to restore a large snapshot by implementing snapshot paging. If you implement snapshot paging, only the non-pageable pages are reloaded on boot instead of reading the whole snapshot back into memory. The pageable memory pages in the snapshot are then read in as needed when they are requested by the OS.

Reading a snapshot begins when your boot loader calls the APIs that you implement to restore the system from a snapshot. The following figure captures the order of function calls made from the OS to the OAL code that you write to restore a snapshot.

Steps to restore a snapshot

The following describes, at a high level, what occurs at each point in the process:

  1. First, modify your boot loader to detect that the device should boot from a snapshot.
  2. SnapRestore is a sample code function that demonstrates how to validate the snapshot header, set up the virtual memory page mapping table, read the snapshot data by using your OEMReadSnapshot function, decompress the snapshot data, and restore the snapshot memory to memory. It is located at %_WINCEROOT%\platform\common\src\common\boot\blcommon\snapsupport.c You can modify the boot loader to call this function to boot from a snapshot, or you can use this sample code as a starting point for your own function.
  3. If you support snapshot paging, your OEMReadSnapshot() function is called to read in the pages of the snapshot that are required to boot. If you do not supply this function, the whole snapshot will be read into memory before the boot process can continue.
  4. After you read the snapshot image into memory, you must restore the CPU context that you saved in OEMTakeCPUSnapshot. This function is typically written in assembly language. After the CPU context has been restored, execution will resume in OEMSnapshotResume.
  5. OEMSnapshotResume is the first function that is called after booting from a snapshot. Snapshots are taken when the device is in a suspended state. When you boot from a snapshot, you must resume the system as if the device is resuming from a power-off state. In this function you reinitialize the device as if it had been cold booted. After returning from this function, the device should be in the state it was in when the snapshot was taken.

Implement APIs to Restore a Snapshot describes the functions that you must implement in order to restore a snapshot.

In This Section

See Also

Concepts

Snapshot Boot Development
Modify the Boot Loader for Snapshot Boot