Patchwork [U-Boot,RFC,17/22] sandbox: Adjust bootm command to work with sandbox

login
register
mail settings
Submitter Simon Glass
Date Jan. 10, 2013, 2:58 p.m.
Message ID <1357829905-6579-18-git-send-email-sjg@chromium.org>
Download mbox | patch
Permalink /patch/211040/
State RFC
Headers show

Comments

Simon Glass - Jan. 10, 2013, 2:58 p.m.
Use map_sysmem() when converting from addresses to pointers, so that
bootm can be used with sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 common/cmd_bootm.c |   25 ++++++++++++-------------
 1 files changed, 12 insertions(+), 13 deletions(-)

Patch

diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 33320cb..2dbf4df 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -325,12 +325,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) {
@@ -338,8 +341,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");
@@ -347,8 +349,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)
@@ -367,9 +368,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);
@@ -386,9 +387,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 "
@@ -404,9 +404,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);