bootm: Use print_decomp_msg() in all cases
Refactor to allow this function to be used to announce the image being loaded regardless of compression type and even when there is no decompression. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
		
							parent
							
								
									6ed4dc7876
								
							
						
					
					
						commit
						8fd6a4b514
					
				|  | @ -266,13 +266,25 @@ static int bootm_find_other(cmd_tbl_t *cmdtp, int flag, int argc, | ||||||
| } | } | ||||||
| #endif /* USE_HOSTC */ | #endif /* USE_HOSTC */ | ||||||
| 
 | 
 | ||||||
| #if defined(CONFIG_GZIP) || defined(CONFIG_GZIP) || defined(CONFIG_BZIP2) || \ | /**
 | ||||||
| 	defined(CONFIG_LZMA) || defined(CONFIG_LZO) |  * print_decomp_msg() - Print a suitable decompression/loading message | ||||||
| static void print_decomp_msg(const char *type_name) |  * | ||||||
|  |  * @type:	OS type (IH_OS_...) | ||||||
|  |  * @comp_type:	Compression type being used (IH_COMP_...) | ||||||
|  |  * @is_xip:	true if the load address matches the image start | ||||||
|  |  */ | ||||||
|  | static void print_decomp_msg(int comp_type, int type, bool is_xip) | ||||||
| { | { | ||||||
| 	printf("   Uncompressing %s ... ", type_name); | 	const char *name = genimg_get_type_name(type); | ||||||
|  | 
 | ||||||
|  | 	if (comp_type == IH_COMP_NONE) | ||||||
|  | 		printf("   %s %s ... ", is_xip ? "XIP" : "Loading", name); | ||||||
|  | 	else | ||||||
|  | 		printf("   Uncompressing %s ... ", name); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #if defined(CONFIG_GZIP) || defined(CONFIG_GZIP) || defined(CONFIG_BZIP2) || \ | ||||||
|  | 	defined(CONFIG_LZMA) || defined(CONFIG_LZO) | ||||||
| static int handle_decomp_error(const char *algo, size_t size, size_t unc_len, | static int handle_decomp_error(const char *algo, size_t size, size_t unc_len, | ||||||
| 			       int ret) | 			       int ret) | ||||||
| { | { | ||||||
|  | @ -293,24 +305,18 @@ int bootm_decomp_image(int comp, ulong load, ulong image_start, int type, | ||||||
| 		       void *load_buf, void *image_buf, ulong image_len, | 		       void *load_buf, void *image_buf, ulong image_len, | ||||||
| 		       uint unc_len, ulong *load_end) | 		       uint unc_len, ulong *load_end) | ||||||
| { | { | ||||||
| 	const char *type_name = genimg_get_type_name(type); |  | ||||||
| 
 |  | ||||||
| 	*load_end = load; | 	*load_end = load; | ||||||
|  | 	print_decomp_msg(comp, type, load == image_start); | ||||||
| 	switch (comp) { | 	switch (comp) { | ||||||
| 	case IH_COMP_NONE: | 	case IH_COMP_NONE: | ||||||
| 		if (load == image_start) { | 		if (load != image_start) | ||||||
| 			printf("   XIP %s ... ", type_name); |  | ||||||
| 		} else { |  | ||||||
| 			printf("   Loading %s ... ", type_name); |  | ||||||
| 			memmove_wd(load_buf, image_buf, image_len, CHUNKSZ); | 			memmove_wd(load_buf, image_buf, image_len, CHUNKSZ); | ||||||
| 		} |  | ||||||
| 		*load_end = load + image_len; | 		*load_end = load + image_len; | ||||||
| 		break; | 		break; | ||||||
| #ifdef CONFIG_GZIP | #ifdef CONFIG_GZIP | ||||||
| 	case IH_COMP_GZIP: { | 	case IH_COMP_GZIP: { | ||||||
| 		int ret; | 		int ret; | ||||||
| 
 | 
 | ||||||
| 		print_decomp_msg(type_name); |  | ||||||
| 		ret = gunzip(load_buf, unc_len, image_buf, &image_len); | 		ret = gunzip(load_buf, unc_len, image_buf, &image_len); | ||||||
| 		if (ret != 0) { | 		if (ret != 0) { | ||||||
| 			return handle_decomp_error("GUNZIP", image_len, | 			return handle_decomp_error("GUNZIP", image_len, | ||||||
|  | @ -325,7 +331,6 @@ int bootm_decomp_image(int comp, ulong load, ulong image_start, int type, | ||||||
| 	case IH_COMP_BZIP2: { | 	case IH_COMP_BZIP2: { | ||||||
| 		size_t size = unc_len; | 		size_t size = unc_len; | ||||||
| 
 | 
 | ||||||
| 		print_decomp_msg(type_name); |  | ||||||
| 		/*
 | 		/*
 | ||||||
| 		 * If we've got less than 4 MB of malloc() space, | 		 * If we've got less than 4 MB of malloc() space, | ||||||
| 		 * use slower decompression algorithm which requires | 		 * use slower decompression algorithm which requires | ||||||
|  | @ -348,7 +353,6 @@ int bootm_decomp_image(int comp, ulong load, ulong image_start, int type, | ||||||
| 		SizeT lzma_len = unc_len; | 		SizeT lzma_len = unc_len; | ||||||
| 		int ret; | 		int ret; | ||||||
| 
 | 
 | ||||||
| 		print_decomp_msg(type_name); |  | ||||||
| 		ret = lzmaBuffToBuffDecompress(load_buf, &lzma_len, | 		ret = lzmaBuffToBuffDecompress(load_buf, &lzma_len, | ||||||
| 					       image_buf, image_len); | 					       image_buf, image_len); | ||||||
| 		if (ret != SZ_OK) { | 		if (ret != SZ_OK) { | ||||||
|  | @ -365,8 +369,6 @@ int bootm_decomp_image(int comp, ulong load, ulong image_start, int type, | ||||||
| 		size_t size = unc_len; | 		size_t size = unc_len; | ||||||
| 		int ret; | 		int ret; | ||||||
| 
 | 
 | ||||||
| 		print_decomp_msg(type_name); |  | ||||||
| 
 |  | ||||||
| 		ret = lzop_decompress(image_buf, image_len, load_buf, &size); | 		ret = lzop_decompress(image_buf, image_len, load_buf, &size); | ||||||
| 		if (ret != LZO_E_OK) | 		if (ret != LZO_E_OK) | ||||||
| 			return handle_decomp_error("LZO", size, unc_len, ret); | 			return handle_decomp_error("LZO", size, unc_len, ret); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue