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:
Initially, in the case of a cold boot, rebootDesc is NULL. The reboot program subsequently initializes rebootDesc with a non-zero value (see "Reboot Program Initialization") . During the subsequent hot boot, the value of rebootDesc is passed from the reboot program to the bootconf program (see "Hot Reboot").
For a hot boot, rebootDesc is also initially set to NULL. The bootconf program then re-initializes the field with the argument passed from the reboot program (see Example 3-5).
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.
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); } } }