예제 #1
0
void CliManagerInit(void) {

	UNS_8 prmpt[16] = "Command:> ";

	/* Initialize commands */
	CLI_debug_add_commands();
	CLI_file_add_commands();
	CLI_upgrade_add_commands();
	CLI_config_add_commands();
	/* Initialize line prompt and parser */
	key_line_init(prmpt);
}
예제 #2
0
파일: s1l_bootmgr.c 프로젝트: sobczyk/bsp
/***********************************************************************
 *
 * 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);
}