ChorusOS 4.0 Porting Guide

reboot_start()

The reboot_start() function installs and launches the reboot program. The reboot program is installed only once during the first cold boot. It maintains a section of the system state that must be kept over subsequent hot reboots. reboot_start() differentiates between a cold boot and a hot boot by testing the value of the rebootDesc field in the bootConf structure:

reboot_start() calls binInstallByType() (see "binInstallByMask and binInstallByType()") to install the reboot program. It then retrieves the descriptor pointing to the reboot program binary and jumps to its entry point, passing the address of the bootConf structure as an argument.

reboot_start() assumes that the memory banks containing the reboot program have already been installed and that the destination addresses are already accessible.

Example 3-10 is reboot_start() source code provided in kernel/snippet/nucleus/boot_tools/reboot_start.c.


Example 3-8 reboot_start()

    void
reboot_start(void* cookie)
{
    int i;

    if (bootConf->rebootDesc == 0) {
        /*
         * This is a cold reboot. Install reboot program
         */
        binInstallByType(BIN_REBOOT);
    }

    for (i = 0; i < bootConf->numBins; ++i) {
        BinDesc* bin = &bootConf->binDesc[i];
        if (bin->type == BIN_REBOOT) {
            (* (RebootEntry) bin->entry)(bootConf, cookie);
        }
    }
}