ChorusOS 4.0 Porting Guide

Rebooting The New System Image

The ChorusOS boot monitor is implemented as an application on top of ChorusOS. The boot monitor reads the new system image from an external medium (for example, a network) and stores that image in a buffer. It then performs a sysReboot() request that eventually invokes the rebootNew() service routine. To simplify the reboot implementation, the ChorusOS boot monitor has to use a ChorusOS system, configured with flat memory management, model.s. Example 4-6 is the service routine source code provided in src/nucleus/bsp/powerpc/sbc8260/src/reboot/reboot.c.


Example 4-6 rebootNew() Routine

    void
rebootNew(KnRebootReq* req)
{
    KnNewRebootReq* nreq = >u.nw;
    BootParams* bootp;

    printf ("Boot new image ...\n");

    if (nreq->workSize < (launch_end - launch_start) + sizeof(BootParams)) {
        printf ("Not enough working memory to reboot\n");
        printf ("Try cold reboot\n");
        resetOp(0);
    }

    /*
     * Disable I/D-Caches.
     */
    cachesDisable();

    if (nreq->ipcSiteNb) {
        /*
         * Get Chours IPC site number from the loader
         */
        bootParams.ipcSiteNb = nreq->ipcSiteNb;
    }

    /*
     * Copy bootParams at the end of the working area
     */
    bootp = (BootParams*) (nreq->workAddr + nreq->workSize - 
                           sizeof(BootParams));
    bcopy(&bootParams, bootp, sizeof(BootParams));

    /*
     * Copy the launch routine to the working memory
     */
    bcopy(launch_start, (void*) nreq->workAddr, launch_end - launch_start);

    /*
     * Jump to the copied launch code
     */
    ((launch) nreq->workAddr)(nreq->dstAddr, nreq->srcAddr, 
                          nreq->size, nreq->entry, bootp);
}

The caller (that is, sysReboot()) provides a working area that is separate to that from the current system image, including the currently executing reboot program. The buffer, holding the new system image, and the system image destination area are also outside the working area. In the working area, the rebootNew() routine installs the bootParams structure and a small positional independent program, called launch(), and then runs launch(). The launch() program copies the new system image from the buffer to the destination address and jumps to its entry point, passing the address of the bootParams structure as the first argument. See "launch() Routine" for details.