Take the main.c from the FADS8xx system:
#include "ipl.h"
unsigned int image;
int
main (void)
{
/*
* Image is located at 0x2840000
* Therefore, we don't require an image_download_8250 function
*/
image = image_scan (0x2840000, 0x2841000);
/*
* Copy startup to ram; it will do any necessary work on the image
*/
image_setup (image);
/*
* Set up link register and jump to startup entry point
*/
image_start (image);
return (0);
}
In this case, we have a linearly addressable flash memory device that contains the image — that's why we don't need the image_download_8250() function.
The next function called is image_scan(), which is given a very narrow range of addresses to scan for the image. We give it such a small range because we know where the image is on this system — there's very little point searching for it elsewhere.
Then we call image_setup() with the address that we got from the image_scan(). This copies the startup code to RAM.
Finally, we call image_start() to transfer control to the startup program. We don't expect this function to return — the reason we have the return (0); statement is to keep the C compiler happy (otherwise it would complain about "Missing return value from function main").