Image storage methods

The following diagrams show some common methods for storing bootable images, and what the IPL and startup code copy and extract to RAM in order to prepare the OS to run.

In the pseudo-code examples below, the image_paddr variable has the source location of the image in linear ROM, and the ram_paddr variable has the image's destination in RAM. For more information about the startup header and its members, see The startup header in this chapter.

Linear ROM XIP boot image

The following illustration shows an XIP image stored on a linearly-mapped ROM device. The IPL needs to copy only the startup code into RAM:

Here are the steps required in the IPL:

checksum (image_paddr, startup_size)
checksum (image_paddr + startup_size, stored_size - startup_size)
copy (image_paddr, ram_paddr, startup_size)
jump (startup_vaddr)

Linear ROM compressed boot image

If the the image on the linearly-mapped device is compressed, XIP can't be used. The IPL copies the startup code into RAM, and this code must extract the compressed image into RAM. Because the compressed image is on linearly-addressed media, the startup code can extract it directly from ROM to its final location in RAM:

Here are the steps required in the IPL:

checksum (image_paddr, startup_size)
checksum (image_paddr + startup_size, stored_size - startup_size)
copy (image_paddr, ram_paddr, startup_size)
jump (startup_vaddr)

And here's the step required in the startup code:

uncompress (ram_paddr + startup_size, image_paddr + startup_size,
            stored_size - startup_size)

ROM non-XIP image

If XIP won't be used and the image isn't compressed, the IPL copies the startup code into RAM, and this code simply copies the uncompressed image to the appropriate location (ram_paddr) in RAM:

Here are the steps required in the IPL:

checksum (image_paddr, startup_size)
checksum (image_paddr + startup_size, stored_size - startup_size)
copy (image_paddr, ram_paddr, startup_size)
jump (startup_vaddr)

And here's the step required in the startup code:

copy (ram_paddr + startup_size, image_paddr + startup_size,
      stored_size - startup_size)

Disk/network image (x86)

In the case shown below, an image is loaded from a disk or a network onto an x86 system with a BIOS or UEFI, which looks after loading the image into RAM (see x86 disk boot IPLs). The BIOS or UEFI doesn't know where to jump, so it jumps to its default address, which is the start of the image. We place a small QNX IPL at the start of the image; this IPL simply jumps to the startup code at startup_vaddr:

Since the BIOS or UEFI handles everything else, the only step required in the IPL is the jump instruction:

jump (startup_vaddr)

Disk/network compressed image (x86)

If the image loaded from disk or a network is compressed, the IPL still jumps to the startup code (which can never be compressed), and the startup code extracts the image to its required location in RAM:

Here's the step required in the startup:

uncompress (ram_paddr + startup_size, image_paddr + startup_size,
            stored_size - startup_size)