IPL code structure

The IPL code is structured in two stages. The first stage is written in assembly language; it sets up just enough of an environment for the second stage, written in C, to run. Generally, the minimum work done here is to set up the DRAM controllers, initialize the various registers, and set up the chip selects so that you can address your hardware.

Generally, the IPL assembly-language source name begins with "init" (e.g. init8xx.s for the MPC8xxFADS board); the C file is always called main.c.

Once your assembly-language routine has set up the minimum amount required to transfer control to the C language portion, the main() program calls the following functions in order:

This function is responsible for getting the image from wherever it may be located. If the image is located in linear memory, this function isn't required (the image is already "downloaded").

If you're downloading the image from a custom piece of hardware, you should call your function image_download_hw(), where the hw part is replaced with a descriptive name for the hardware, e.g. image_download_x25().

This function is given a start and an end address to search for a boot image. If successful, it returns a pointer to the start of the image. It's possible to search within an address range that contains more than one image. If there are multiple images, and one of them has a bad checksum, then the next image is used. If there are multiple images with good checksums, the startup header is examined, and the one with the higher version number is used. Note that the scan will occur only between the specified addresses.
This function does the work of copying the necessary part of the image into RAM.
This function will jump to the start of the image loaded into RAM, which will turn control over to the startup program.