diff options
Diffstat (limited to 'common/cmd_bootm.c')
| -rw-r--r-- | common/cmd_bootm.c | 170 | 
1 files changed, 22 insertions, 148 deletions
| diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 15f4599d4..05130b693 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -93,11 +93,6 @@ static int do_imls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);  static void fixup_silent_linux(void);  #endif -static image_header_t *image_get_kernel(ulong img_addr, int verify); -#if defined(CONFIG_FIT) -static int fit_check_kernel(const void *fit, int os_noffset, int verify); -#endif -  static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,  				char * const argv[], bootm_headers_t *images,  				ulong *os_data, ulong *os_len); @@ -306,7 +301,7 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]  #if defined(CONFIG_OF_LIBFDT)  		/* find flattened device tree */ -		ret = boot_get_fdt(flag, argc, argv, &images, +		ret = boot_get_fdt(flag, argc, argv, IH_ARCH_DEFAULT, &images,  				   &images.ft_addr, &images.ft_len);  		if (ret) {  			puts("Could not find a valid device tree\n"); @@ -336,12 +331,15 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress)  	ulong image_len = os.image_len;  	__maybe_unused uint unc_len = CONFIG_SYS_BOOTM_LEN;  	int no_overlap = 0; +	void *load_buf, *image_buf;  #if defined(CONFIG_LZMA) || defined(CONFIG_LZO)  	int ret;  #endif /* defined(CONFIG_LZMA) || defined(CONFIG_LZO) */  	const char *type_name = genimg_get_type_name(os.type); +	load_buf = map_sysmem(load, image_len); +	image_buf = map_sysmem(image_start, image_len);  	switch (comp) {  	case IH_COMP_NONE:  		if (load == blob_start || load == image_start) { @@ -349,8 +347,7 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress)  			no_overlap = 1;  		} else {  			printf("   Loading %s ... ", type_name); -			memmove_wd((void *)load, (void *)image_start, -					image_len, CHUNKSZ); +			memmove_wd(load_buf, image_buf, image_len, CHUNKSZ);  		}  		*load_end = load + image_len;  		puts("OK\n"); @@ -358,8 +355,7 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress)  #ifdef CONFIG_GZIP  	case IH_COMP_GZIP:  		printf("   Uncompressing %s ... ", type_name); -		if (gunzip((void *)load, unc_len, -				(uchar *)image_start, &image_len) != 0) { +		if (gunzip(load_buf, unc_len, image_buf, &image_len) != 0) {  			puts("GUNZIP: uncompress, out-of-mem or overwrite "  				"error - must RESET board to recover\n");  			if (boot_progress) @@ -378,9 +374,9 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress)  		 * use slower decompression algorithm which requires  		 * at most 2300 KB of memory.  		 */ -		int i = BZ2_bzBuffToBuffDecompress((char *)load, -					&unc_len, (char *)image_start, image_len, -					CONFIG_SYS_MALLOC_LEN < (4096 * 1024), 0); +		int i = BZ2_bzBuffToBuffDecompress(load_buf, &unc_len, +			image_buf, image_len, +			CONFIG_SYS_MALLOC_LEN < (4096 * 1024), 0);  		if (i != BZ_OK) {  			printf("BUNZIP2: uncompress or overwrite error %d "  				"- must RESET board to recover\n", i); @@ -397,9 +393,8 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress)  		SizeT lzma_len = unc_len;  		printf("   Uncompressing %s ... ", type_name); -		ret = lzmaBuffToBuffDecompress( -			(unsigned char *)load, &lzma_len, -			(unsigned char *)image_start, image_len); +		ret = lzmaBuffToBuffDecompress(load_buf, &lzma_len, +					       image_buf, image_len);  		unc_len = lzma_len;  		if (ret != SZ_OK) {  			printf("LZMA: uncompress or overwrite error %d " @@ -415,9 +410,8 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress)  	case IH_COMP_LZO:  		printf("   Uncompressing %s ... ", type_name); -		ret = lzop_decompress((const unsigned char *)image_start, -					  image_len, (unsigned char *)load, -					  &unc_len); +		ret = lzop_decompress(image_buf, image_len, load_buf, +				      &unc_len);  		if (ret != LZO_E_OK) {  			printf("LZO: uncompress or overwrite error %d "  			      "- must RESET board to recover\n", ret); @@ -797,54 +791,6 @@ static image_header_t *image_get_kernel(ulong img_addr, int verify)  }  /** - * fit_check_kernel - verify FIT format kernel subimage - * @fit_hdr: pointer to the FIT image header - * os_noffset: kernel subimage node offset within FIT image - * @verify: data CRC verification flag - * - * fit_check_kernel() verifies integrity of the kernel subimage and from - * specified FIT image. - * - * returns: - *     1, on success - *     0, on failure - */ -#if defined(CONFIG_FIT) -static int fit_check_kernel(const void *fit, int os_noffset, int verify) -{ -	fit_image_print(fit, os_noffset, "   "); - -	if (verify) { -		puts("   Verifying Hash Integrity ... "); -		if (!fit_image_verify(fit, os_noffset)) { -			puts("Bad Data Hash\n"); -			bootstage_error(BOOTSTAGE_ID_FIT_CHECK_HASH); -			return 0; -		} -		puts("OK\n"); -	} -	bootstage_mark(BOOTSTAGE_ID_FIT_CHECK_ARCH); - -	if (!fit_image_check_target_arch(fit, os_noffset)) { -		puts("Unsupported Architecture\n"); -		bootstage_error(BOOTSTAGE_ID_FIT_CHECK_ARCH); -		return 0; -	} - -	bootstage_mark(BOOTSTAGE_ID_FIT_CHECK_KERNEL); -	if (!fit_image_check_type(fit, os_noffset, IH_TYPE_KERNEL) && -	    !fit_image_check_type(fit, os_noffset, IH_TYPE_KERNEL_NOLOAD)) { -		puts("Not a kernel image\n"); -		bootstage_error(BOOTSTAGE_ID_FIT_CHECK_KERNEL); -		return 0; -	} - -	bootstage_mark(BOOTSTAGE_ID_FIT_CHECKED); -	return 1; -} -#endif /* CONFIG_FIT */ - -/**   * boot_get_kernel - find kernel image   * @os_data: pointer to a ulong variable, will hold os data start address   * @os_len: pointer to a ulong variable, will hold os data length @@ -864,12 +810,8 @@ static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,  	ulong		img_addr;  	const void *buf;  #if defined(CONFIG_FIT) -	const void	*fit_hdr;  	const char	*fit_uname_config = NULL;  	const char	*fit_uname_kernel = NULL; -	const void	*data; -	size_t		len; -	int		cfg_noffset;  	int		os_noffset;  #endif @@ -946,84 +888,16 @@ static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,  		break;  #if defined(CONFIG_FIT)  	case IMAGE_FORMAT_FIT: -		fit_hdr = buf; -		printf("## Booting kernel from FIT Image at %08lx ...\n", -				img_addr); - -		if (!fit_check_format(fit_hdr)) { -			puts("Bad FIT kernel image format!\n"); -			bootstage_error(BOOTSTAGE_ID_FIT_FORMAT); -			return NULL; -		} -		bootstage_mark(BOOTSTAGE_ID_FIT_FORMAT); - -		if (!fit_uname_kernel) { -			/* -			 * no kernel image node unit name, try to get config -			 * node first. If config unit node name is NULL -			 * fit_conf_get_node() will try to find default config -			 * node -			 */ -			bootstage_mark(BOOTSTAGE_ID_FIT_NO_UNIT_NAME); -#ifdef CONFIG_FIT_BEST_MATCH -			if (fit_uname_config) -				cfg_noffset = -					fit_conf_get_node(fit_hdr, -							  fit_uname_config); -			else -				cfg_noffset = -					fit_conf_find_compat(fit_hdr, -							     gd->fdt_blob); -#else -			cfg_noffset = fit_conf_get_node(fit_hdr, -							fit_uname_config); -#endif -			if (cfg_noffset < 0) { -				bootstage_error(BOOTSTAGE_ID_FIT_NO_UNIT_NAME); -				return NULL; -			} -			/* save configuration uname provided in the first -			 * bootm argument -			 */ -			images->fit_uname_cfg = fdt_get_name(fit_hdr, -								cfg_noffset, -								NULL); -			printf("   Using '%s' configuration\n", -				images->fit_uname_cfg); -			bootstage_mark(BOOTSTAGE_ID_FIT_CONFIG); - -			os_noffset = fit_conf_get_kernel_node(fit_hdr, -								cfg_noffset); -			fit_uname_kernel = fit_get_name(fit_hdr, os_noffset, -							NULL); -		} else { -			/* get kernel component image node offset */ -			bootstage_mark(BOOTSTAGE_ID_FIT_UNIT_NAME); -			os_noffset = fit_image_get_node(fit_hdr, -							fit_uname_kernel); -		} -		if (os_noffset < 0) { -			bootstage_error(BOOTSTAGE_ID_FIT_CONFIG); -			return NULL; -		} - -		printf("   Trying '%s' kernel subimage\n", fit_uname_kernel); - -		bootstage_mark(BOOTSTAGE_ID_FIT_CHECK_SUBIMAGE); -		if (!fit_check_kernel(fit_hdr, os_noffset, images->verify)) +		os_noffset = fit_image_load(images, FIT_KERNEL_PROP, +				img_addr, +				&fit_uname_kernel, fit_uname_config, +				IH_ARCH_DEFAULT, IH_TYPE_KERNEL, +				BOOTSTAGE_ID_FIT_KERNEL_START, +				FIT_LOAD_IGNORED, os_data, os_len); +		if (os_noffset < 0)  			return NULL; -		/* get kernel image data address and length */ -		if (fit_image_get_data(fit_hdr, os_noffset, &data, &len)) { -			puts("Could not find kernel subimage data!\n"); -			bootstage_error(BOOTSTAGE_ID_FIT_KERNEL_INFO_ERR); -			return NULL; -		} -		bootstage_mark(BOOTSTAGE_ID_FIT_KERNEL_INFO); - -		*os_len = len; -		*os_data = (ulong)data; -		images->fit_hdr_os = (void *)fit_hdr; +		images->fit_hdr_os = map_sysmem(img_addr, 0);  		images->fit_uname_os = fit_uname_kernel;  		images->fit_noffset_os = os_noffset;  		break; @@ -1820,7 +1694,7 @@ static int bootz_start(cmd_tbl_t *cmdtp, int flag, int argc,  #if defined(CONFIG_OF_LIBFDT)  	/* find flattened device tree */ -	ret = boot_get_fdt(flag, argc, argv, images, +	ret = boot_get_fdt(flag, argc, argv, IH_ARCH_DEFAULT, images,  			   &images->ft_addr, &images->ft_len);  	if (ret) {  		puts("Could not find a valid device tree\n"); |