Exemple #1
0
/***********************************************************************
 *
 * Function: blk_boot
 *
 * Purpose: Load am image from the block device
 *
 * Processing:
 *     See function.
 *
 * Parameters: None
 *
 * Outputs: None
 *
 * Returns: FALSE if the operation failed, otherwise TRUE.
 *
 * Notes: None
 *
 **********************************************************************/
BOOL_32 blk_boot(void) 
{
	FILE_DATA_T fdata;
	BOOL_32 loaded = FALSE;

	switch (syscfg.aboot.flt)
	{
		case FLT_RAW:
			/* Use stored NAND parameters for the load */
			loaded = raw_load(&fdata, syscfg.aboot.loadaddr,
				syscfg.aboot.fname, SRC_BLKDEV);
			sysinfo.lfile.loadaddr = syscfg.aboot.loadaddr;
			sysinfo.lfile.startaddr = (PFV) syscfg.aboot.startaddr;
			sysinfo.lfile.num_bytes = fdata.num_bytes;
			break;

		case FLT_SREC:
			loaded = srec_parse(&fdata, SRC_BLKDEV, syscfg.aboot.fname);
			sysinfo.lfile.loadaddr = fdata.loadaddr;
			sysinfo.lfile.startaddr = (PFV) fdata.startaddr;
			sysinfo.lfile.num_bytes = fdata.num_bytes;
			break;

		case FLT_BIN:
			/* TBD not supported yet */
			break;

		case FLT_ELF:
			/* TBD not supported yet */
			break;

		default:
			break;
	}

	sysinfo.lfile.flt = FLT_RAW;
	sysinfo.lfile.contiguous = FALSE; /* Doesn't matter on autoboot */
	sysinfo.lfile.loaded = loaded;

	return loaded;
}
/***********************************************************************
 *
 * Function: cmd_load
 *
 * Purpose: Load command
 *
 * Processing:
 *     For the load command, start parsing subcommand elements and
 *     route to the specific handler.
 *
 * Parameters: None
 *
 * Outputs: None
 *
 * Returns: Always returns TRUE
 *
 * Notes: None
 *
 **********************************************************************/
BOOL_32 cmd_load(void) {
	UNS_8 *curp;
	UNS_32 addr;
	BOOL_32 processed = TRUE, loaded = FALSE;
	FILE_DATA_T fdata;
	SRC_LOAD_T src = SRC_TERM;
	INT_32 nexidx;
	UNS_8 *fname;

	if (parse_get_entry_count() >= 3) 
	{
		/* Get source */
		curp = get_parsed_entry(1);
		nexidx = 2;
		if (str_cmp(curp, "term") == 0) 
		{
			/* Clear break */
			term_break();
			src = SRC_TERM;
		}
		else if (str_cmp(curp, "blk") == 0) 
		{
			src = SRC_BLKDEV;
			nexidx = 3;
		}
		else if (str_cmp(curp, "flash") == 0) 
		{
			src = SRC_NAND;
		}
		else 
		{
			term_dat_out_crlf(invalsrc_msg);
			processed = FALSE;
		}

		/* Get file type */
		curp = get_parsed_entry(nexidx);
		fdata.flt = FLT_NONE;
		if (str_cmp(curp, "elf") == 0) 
		{
			fdata.flt = FLT_ELF;
		}
		else if (str_cmp(curp, "raw") == 0) 
		{
			fdata.flt = FLT_RAW;
		}
		else if (str_cmp(curp, "bin") == 0) 
		{
			fdata.flt = FLT_BIN;
		}
		else if (str_cmp(curp, "srec") == 0) 
		{
			fdata.flt = FLT_SREC;
		}
		else 
		{
			fdata.flt = FLT_NONE;
			term_dat_out(unkft_msg);
			term_dat_out_crlf(curp);
			processed = FALSE;
		}

		/* Next index */
		nexidx++;

		/* Handle each file type */
		if (processed == TRUE) 
		{
			/* Get filename */
			fname = get_parsed_entry(2);

			switch (fdata.flt) 
			{
				case FLT_RAW:
					/* Get load address */
					curp = get_parsed_entry(nexidx);
					loaded = str_hex_to_val(curp, &addr);
					if (loaded == TRUE) 
					{
						fdata.loadaddr = addr;
						fdata.startaddr = (PFV) addr;
					}
					else 
					{
						term_dat_out_crlf(rawna_msg);
					}

					/* Start address */
					nexidx++;
					curp = get_parsed_entry(nexidx);
					if (curp != NULL) 
					{
						loaded &= str_hex_to_val(curp, &addr);
						if (loaded == TRUE) 
						{
							fdata.startaddr = (PFV) addr;
						}
					}

					if (loaded == TRUE) 
					{
						loaded = raw_load(&fdata, fdata.loadaddr,
							fname, src);
					}

					processed = TRUE;
					break;

				case FLT_BIN:
					processed = TRUE; /* TBD not supported yet */
					break;

				case FLT_SREC:
					loaded = srec_parse(&fdata, src, fname);
					break;

				case FLT_ELF:
					processed = TRUE; /* TBD not supported yet */
					break;

				default:
					break;
			}
		}
	}

	if (loaded == TRUE) 
	{
		term_dat_out_crlf(floaded_msg);
		sysinfo.lfile.loadaddr = fdata.loadaddr;
		sysinfo.lfile.flt = fdata.flt;
		sysinfo.lfile.num_bytes = fdata.num_bytes;
		sysinfo.lfile.startaddr = fdata.startaddr;
		sysinfo.lfile.contiguous = fdata.contiguous;
		sysinfo.lfile.loaded = TRUE;
	}
	else 
	{
		term_dat_out_crlf(notloaded_msg);
		sysinfo.lfile.loadaddr = 0xFFFFFFFF;
		sysinfo.lfile.flt = FLT_NONE;
		sysinfo.lfile.num_bytes = 0;
		sysinfo.lfile.startaddr = (PFV) 0xFFFFFFFF;
		processed = FALSE;
	}

	return TRUE;
}