Modify the Boot Loader for Snapshot Boot (Compact 2013)


You must complete the following tasks in order to modify your boot loader to boot from a snapshot:

  • Modify your boot loader to detect the presence of a snapshot. To detect that you should boot from a snapshot, you could write a flag to persistent storage when you have taken a snapshot.
  • If you compress your snapshot, reserve boot loader memory to decompress the snapshot. Your decompression buffer should be a multiple of your CPU architecture’s page size.
  • Ensure that you have a driver that can access your persistent storage during the boot loader phase, or store your snapshot in NOR flash which does not require a driver. If your driver requires OS support to function, you will have to either modify the driver to remove the dependencies it has on the OS, or chose another storage medium. Storing your snapshot in NAND flash is typically a good choice because a driver to access it during the boot loader phase is usually available.
  • Ensure that the memory management unit (MMU) is enabled before you restore a snapshot. The MMU must be enabled to map the page table addresses that you restore from the snapshot to physical addresses.
  • Write a function to restore the CPU state from the snapshot image. That function is typically written in assembly language. Once the CPU context has been restored, execution will resume in OEMSnapshotResume. When OEMSnapshotResume() returns, the system is in the state it was in when the snapshot was captured.
    The function you write to restore the CPU state does not return, because you replace the current CPU context with the CPU context saved in the snapshot.
  • Modify your boot loader to validate the snapshot header, read in the snapshot page table, and set up the virtual memory page mapping table for the snapshot page tables you read in. The SnapRestore() function in the Snapshot Boot Sample Code illustrates how to accomplish these tasks.

If you support snapshot paging (see OEMReadSnapshot), your boot loader should not read in the uncompressed pageable portion of the snapshot. The pageable memory in the snapshot will be requested by the OS as needed and read in using your OEMReadSnashot() function. If you did not provide support for snapshot paging, then your boot loader must read the whole snapshot image into memory.