diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2020-11-10 15:07:31 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-11-10 15:07:31 +0100 |
commit | 0b0eada569b198aa3882cfec5874bc35a8a0fa14 (patch) | |
tree | 061ca4528bfaee38df3faae6ff1a6be6d4993fe6 /common | |
parent | 34ea8b9317afad6ed2cb702c911cbcbad9d3bf23 (diff) | |
parent | 706ef1bf6fed8dd2c75c469ad4bc758da2cb4cf3 (diff) | |
download | barebox-0b0eada569b198aa3882cfec5874bc35a8a0fa14.tar.gz barebox-0b0eada569b198aa3882cfec5874bc35a8a0fa14.tar.xz |
Merge branch 'for-next/misc'
Diffstat (limited to 'common')
-rw-r--r-- | common/uimage.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/common/uimage.c b/common/uimage.c index a84b8fddc4..9abfbcf3ba 100644 --- a/common/uimage.c +++ b/common/uimage.c @@ -27,6 +27,7 @@ #include <rtc.h> #include <filetype.h> #include <memory.h> +#include <zero_page.h> static inline int uimage_is_multi_image(struct uimage_handle *handle) { @@ -359,7 +360,10 @@ static int uimage_sdram_flush(void *buf, unsigned int len) } } - memcpy(uimage_buf + uimage_size, buf, len); + if (zero_page_contains((unsigned long)uimage_buf + uimage_size)) + zero_page_memcpy(uimage_buf + uimage_size, buf, len); + else + memcpy(uimage_buf + uimage_size, buf, len); uimage_size += len; @@ -388,7 +392,20 @@ struct resource *file_to_sdram(const char *filename, unsigned long adr) goto out; } - now = read_full(fd, (void *)(res->start + ofs), BUFSIZ); + if (zero_page_contains(res->start + ofs)) { + void *tmp = malloc(BUFSIZ); + if (!tmp) + now = -ENOMEM; + else + now = read_full(fd, tmp, BUFSIZ); + + if (now > 0) + zero_page_memcpy((void *)(res->start + ofs), tmp, now); + free(tmp); + } else { + now = read_full(fd, (void *)(res->start + ofs), BUFSIZ); + } + if (now < 0) { release_sdram_region(res); res = NULL; |