Пример #1
0
unsigned long do_go_exec (ulong (*entry)(int, char *[]), int argc, char *argv[])
{   
   ulong magic;
   bootm_headers_t images;
   magic = *(ulong *)((ulong)entry +4*9);
   if(0x016f2818 != magic) 
	 return entry (argc, argv);
   images.ep = (ulong)entry;
   return do_bootm_linux(0,argc,argv,&images);
}
Пример #2
0
int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){
	ulong addr, data, len;
	uint unc_len = CFG_BOOTM_LEN;
	int i;
	image_header_t *hdr = &header;
#ifdef CONFIG_TPLINK_IMAGE_HEADER
	tplink_image_header_t *fileTag;
#endif

	if(argc < 2){
		addr = load_addr;
	} else {
		addr = simple_strtoul(argv[1], NULL, 16);
	}

	printf("Booting image at: 0x%08lX\n", addr);

#ifndef CONFIG_TPLINK_IMAGE_HEADER
	memmove(&header, (char *)addr, sizeof(image_header_t));
	print_image_hdr(hdr);

	data = addr + sizeof(image_header_t);
#else
	fileTag = (tplink_image_header_t *)addr;
	print_image_hdr(fileTag);

	fake_image_header(hdr, fileTag);

	data = addr + TAG_LEN;
#endif /* !CONFIG_TPLINK_IMAGE_HEADER */

	len = ntohl(hdr->ih_size);

	/*
	 * We have reached the point of no return: we are going to
	 * overwrite all exception vector code, so we cannot easily
	 * recover from any failures any more...
	 */
#ifdef CONFIG_NETCONSOLE
	/*
	* Stop the ethernet stack if NetConsole could have
	* left it up
	*/
	eth_halt();
#endif

	/* TODO: should we flush caches for kernel? */
	/*
	 * Flush everything, restore caches for linux
	 */
	//mips_cache_flush();
	//mips_icache_flush_ix();

	/* XXX - this causes problems when booting from flash */
	/* dcache_disable(); */

	/*	case IH_COMP_LZMA:*/
	puts("Uncompressing kernel image... ");

	i = lzma_inflate((unsigned char *)data, len, (unsigned char*)ntohl(hdr->ih_load), (int *)&unc_len);

	if(i != LZMA_RESULT_OK){
		printf("## Error: LZMA error num: %d\n", i);
		return(-1);
	}

	puts("OK!\n");

#ifdef CONFIG_SILENT_CONSOLE
	fixup_silent_linux();
#endif

	do_bootm_linux(cmdtp, flag, argc, argv);

#ifdef DEBUG
	puts("\n## Error: control returned to monitor - resetting...\n");
	do_reset(cmdtp, flag, argc, argv);
#endif

	return(1);
}
Пример #3
0
int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
	char *s;
	u32 *len_ptr;
	u32 addr, data, len;
	int i, tpl_type, verify;
	u32 unc_len = CFG_BOOTM_LEN;
	image_header_t *hdr = &header;
	tplink_image_header_t *tpl_hdr;

	/*
	 * By default don't verify data CRC checksum,
	 * but allow to enable it, using environment
	 **/
	s = getenv("verify_data");
	verify = (s && (*s == 'y')) ? 1 : 0;

	if (argc < 2) {
		addr = load_addr;
	} else {
		addr = simple_strtoul(argv[1], NULL, 16);
	}

	printf("Booting image from 0x%08lX...\n", addr);

	/* Check what header type we have */
	memmove(&data, (char *)addr, sizeof(u32));
	tpl_type = 0;

	switch (ntohl(data)) {
	case TPL_IH_VERSION_V1:
		tpl_type = 1;

		tpl_hdr = (tplink_image_header_t *)addr;
		print_tpl_ih_v1(tpl_hdr);

		/* Convert to general format */
		tpl_to_uboot_header(hdr, tpl_hdr);
		break;
	case IH_MAGIC:
		print_uboot_ih((image_header_t *)addr);
		memmove(&header, (char *)addr, sizeof(image_header_t));
		break;
	case TPL_IH_VERSION_V2:
	case TPL_IH_VERSION_V3:
	default:
		puts("## Error: unsupported image header\n");
		return 1;
	}

	/* Always verify header CRC */
	if (ih_header_crc(hdr, tpl_type) != 0) {
		puts("## Error: header checksum mismatch!\n");
		return 1;
	}

	/* And data if enabled */
	if (tpl_type) {
		data = addr + sizeof(tplink_image_header_t);
	} else {
		data = addr + sizeof(image_header_t);
	}

	if (ih_data_crc(data, hdr, tpl_type, verify) != 0) {
		puts("## Error: data checksum mismatch!\n");
		return 1;
	}

	puts("\n");

	len = ntohl(hdr->ih_size);
	len_ptr = (u32 *)data;

	/* We support only MIPS */
	if (hdr->ih_arch != IH_CPU_MIPS) {
		puts("## Error: unsupported architecture!\n");
		return 1;
	}

	/* Image type... */
	switch (hdr->ih_type) {
	case IH_TYPE_KERNEL:
		break;
	case IH_TYPE_MULTI:
		/* OS kernel is always in first image */
		len = ntohl(len_ptr[0]);
		data += 8;

		/* Move over list to first image */
		for (i = 1; len_ptr[i]; ++i)
			data += 4;

		break;
	default:
		puts("## Error: unsupported image type!\n");
		return 1;
	}

	/*
	 * We have reached the point of no return: we are going to
	 * overwrite all exception vector code, so we cannot easily
	 * recover from any failures any more...
	 */

#ifdef CONFIG_NETCONSOLE
	/*
	* Stop the ethernet stack if NetConsole could have
	* left it up
	*/
	puts("Stopping network... ");
	eth_halt();
	puts("OK!\n");
#endif

	/* TODO: should we flush caches for kernel? */
	/*
	 * Flush everything, restore caches for linux
	 */
	//mips_cache_flush();
	//mips_icache_flush_ix();

	/* XXX - this causes problems when booting from flash */
	/* dcache_disable(); */

	/* Compression type... */
	switch (hdr->ih_comp) {
	case IH_COMP_LZMA:
		printf("Uncompressing %s... ", ih_img_type(hdr->ih_type));

		/* Try to extract LZMA data... */
		i = lzma_inflate((u8 *)data, len,
			(u8 *)ntohl(hdr->ih_load), (int *)&unc_len);

		/* TODO: more verbose LZMA errors */
		if (i != LZMA_RESULT_OK) {
			puts("ERROR\n");
			printf("## Error: LZMA error '%d'!\n", i);
			return 1;
		}

		puts("OK!\n");
		break;
	default:
		printf("## Error: unsupported compression type '%s'!\n",
			ih_comp_type(hdr->ih_comp));

		return 1;
	}

#ifdef CONFIG_SILENT_CONSOLE
	fixup_silent_linux();
#endif

	do_bootm_linux(cmdtp, flag, argc, argv);

	return 1;
}