Пример #1
0
/***********************************************************************
 *
 * Function: readline
 *
 * Purpose: Read line with line feed
 *
 * Processing:
 *     See function.
 *
 * Parameters:
 *     data : Pointer to line data to fill
 *     src  : Data source
 *
 * Outputs: None
 *
 * Returns: TRUE if the line was loaded, otherwise FALSE
 *
 * Notes: None
 *
 **********************************************************************/
static BOOL_32 readline(UNS_8 *data,
                        SRC_LOAD_T src) 
{
	UNS_32 rb;
	int lastidx, idx;
	BOOL_32 linedone = FALSE, linegood = FALSE;

	lastidx = idx = 0;
	while (linedone == FALSE) 
	{
		switch (src) 
		{
			case SRC_TERM:
				/* Has a break occurred? */
				if (term_break() == TRUE) 
				{
					/* Exit now */
					linedone = TRUE;
				}
				else if (term_dat_in((data + idx), 1) > 0) 
				{
					idx++;
				}
				break;

			case SRC_NAND:
				/* Get a byte from the FLASH */
				/* Get a byte from the SD/MMC card */
				rb = stream_flash_read(&data [idx], 1);
				if (rb == 0) 
				{
					linedone = TRUE;
				}
				idx++;
				break;

			case SRC_BLKDEV:
				/* Get a byte from the SD/MMC card */
				rb = fat_file_read(&data [idx], 1);
				if (rb == 0) 
				{
					linedone = TRUE;
				}
				idx++;
				break;

			case SRC_NONE:
			default:
				return FALSE;
		}

		if (lastidx != idx) 
		{
			if (data [lastidx] == '\r') 
			{
				linedone = TRUE;
				linegood = TRUE;
				data [lastidx] = '\0';
			}

			lastidx = idx;
		}
	}

	data [idx] = '\0';
	str_upper_to_lower(data);
	return linegood;
}
Пример #2
0
/***********************************************************************
 *
 * 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);
}
Пример #3
0
void CLI_Process(void) {
	key_get_command(str);
	str_upper_to_lower(str);
	cmd_process(str);

}