static int command_autoboot(int argc, char *argv[]) { int howlong; char *cp, *prompt; prompt = NULL; howlong = -1; switch(argc) { case 3: prompt = argv[2]; /* FALLTHROUGH */ case 2: howlong = strtol(argv[1], &cp, 0); if (*cp != 0) { sprintf(command_errbuf, "bad delay '%s'", argv[1]); return(CMD_ERROR); } /* FALLTHROUGH */ case 1: return(autoboot(howlong, prompt)); } command_errmsg = "too many arguments"; return(CMD_ERROR); }
int hmain(void) { struct platform_info *pinfo = &platform_info; /* Both red and green led is already truned on at boot.S. */ do_initcall(); print_version(); if (pinfo->is_autoboot) { if (pinfo->is_autoboot(pinfo)) autoboot(); else mediaboot(); } led_off(LED_RED); if (strcmp(CONFIG_DEFAULT_CONSOLE, "none") == 0) change_console(CONFIG_STANDARD_CONSOLE); passwd_authentication(); hermit_command_loop(); }
/* * Called before we go interactive. If we think we can autoboot, and * we haven't tried already, try now. */ void autoboot_maybe() { char *cp; cp = getenv("autoboot_delay"); if ((autoboot_tried == 0) && ((cp == NULL) || strcasecmp(cp, "NO"))) autoboot(-1, NULL); /* try to boot automatically */ }
/*********************************************************************** * * Function: cmd_boot * * Purpose: Autoloads and image and starts boot of it * * Processing: * See function. * * Parameters: None * * Outputs: None * * Returns: TRUE if the command was good, otherwise FALSE * * Notes: None * **********************************************************************/ BOOL_32 cmd_boot(void) { if (autoboot() == TRUE) { menuexit = TRUE; } else { term_dat_out_crlf(cnoboot_msg); } return TRUE; }
/*********************************************************************** * * Function: boot_manager * * Purpose: Handle boot configuation and options * * Processing: * See function. * * Parameters: * allow_boot : TRUE to allow the system to autoboot * * Outputs: None * * Returns: Nothing * * Notes: None * **********************************************************************/ void boot_manager(BOOL_32 allow_boot) { UNS_8 key, str[255]; int i, idx; UNS_32 secsmt; BOOL_32 usedef = FALSE; /* Get runtime configuration */ get_rt_s1lsys_cfg(&sysinfo.sysrtcfg); /* Query FLASH */ sysinfo.nandgeom = flash_init(); /* Get S1L configuration */ if (cfg_override() != FALSE) { cfg_default(&syscfg); usedef = TRUE; } else if (cfg_load(&syscfg) == FALSE) { cfg_default(&syscfg); syscfg.scr.number_entries = 0; cfg_save(&syscfg); usedef = TRUE; } /* Initial system setup */ sys_up(); if (sysinfo.nandgeom == NULL) { term_dat_out_crlf(nanderr_msg); } /* Set saved baud rate */ term_setbaud(syscfg.baudrate); /* Default configuration used? */ if (usedef != FALSE) { term_dat_out_crlf(cfggdef_msg); } /* Display system header */ term_dat_out_crlf((UNS_8 *) ""); term_dat_out_crlf(sysinfo.sysrtcfg.system_name); term_dat_out(bdat_msg); term_dat_out((UNS_8 *) __DATE__); term_dat_out((UNS_8 *) " "); term_dat_out_crlf((UNS_8 *) __TIME__); /* No file currently loaded in memory */ sysinfo.lfile.loadaddr = 0xFFFFFFFF; sysinfo.lfile.flt = FLT_NONE; sysinfo.lfile.num_bytes = 0; sysinfo.lfile.startaddr = (PFV) 0xFFFFFFFF; sysinfo.lfile.loaded = FALSE; /* Initialize commands */ cmd_core_add_commands(); cmd_image_add_commands(); cmd_nand_add_commands(); ucmd_init(); /* Initialize line prompt and parser */ key_line_init(syscfg.prmpt); /* Prompt usually appears */ menuexit = FALSE; /* Use built in script capability? */ if ((syscfg.scr.enabled == TRUE) && (syscfg.scr.number_entries > 0)) { term_dat_out_crlf((UNS_8 *) "Running built-in script...\n"); i = idx = 0; while (i < syscfg.scr.number_entries) { /* Execute commands */ term_dat_out((UNS_8 *) "-S>"); term_dat_out_crlf(&syscfg.scr.script_data[idx]); cmd_process(&syscfg.scr.script_data[idx]); idx = idx + syscfg.scr.entry_size[i] + 1; i++; } } else { /* In prompt bypass mode? */ if (syscfg.aboot.abootsrc != SRC_NONE) menuexit = allow_boot; if ((syscfg.prmpt_to > 0) && (menuexit == TRUE)) { secsmt = get_seconds() + syscfg.prmpt_to; term_dat_out_crlf(kp_msg); while (get_seconds() < secsmt) { if (term_dat_in_ready() > 0) { term_dat_in(&key, 1); menuexit = FALSE; secsmt = get_seconds(); } } } /* Perform autoboot if possible */ if (menuexit == TRUE) { menuexit = autoboot(); } } while (menuexit == FALSE) { key_get_command(str); str_upper_to_lower(str); cmd_process(str); } /* Bring down some system items */ sys_down(); /* Execute program */ jumptoprog(sysinfo.lfile.startaddr); }