All of lore.kernel.org
 help / color / mirror / Atom feed
From: AK Sharma <maskachoska@yahoo.com>
To: u-boot@lists.u-boot-project.org
Cc: Christian Marangi <ansuelsmth@gmail.com>,
	Daniel Schwierzeck <daniel.schwierzeck@gmail.com>,
	Dario Binacchi <dario.binacchi@amarulasolutions.com>,
	Frieder Schrempf <frieder.schrempf@kontron.de>,
	Jerome Forissier <jerome.forissier@arm.com>,
	Marek Vasut <marex@denx.de>,
	Michael Trimarchi <michael@amarulasolutions.com>,
	Tom Rini <trini@konsulko.com>, AK Sharma <maskachoska@yahoo.com>
Subject: [PATCH v1 08/12] boot: image: add weak hooks for the decompression buffer and flush
Date: Wed, 26 Aug 2026 04:12:03 +0530	[thread overview]
Message-ID: <20260825224330.713151-9-maskachoska@yahoo.com> (raw)
In-Reply-To: <20260825224330.713151-1-maskachoska@yahoo.com>

Add two weak hooks around the bootm image decompression:
image_get_decomp_buf() lets a platform redirect the decompression
destination (e.g. to an uncached window), and image_decomp_flush() lets
it flush the caches over the decompressed image. Both default to no-ops,
so existing platforms are unaffected. The EN75xx uses them to keep the
kernel coherent on its cache-coherent CM.

Signed-off-by: AK Sharma <maskachoska@yahoo.com>
---
 boot/image.c    | 34 +++++++++++++++++++++++++++-------
 include/image.h |  5 +++++
 2 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/boot/image.c b/boot/image.c
index 185d52ba..680a78da 100644
--- a/boot/image.c
+++ b/boot/image.c
@@ -442,15 +442,31 @@ int image_decomp_type(const unsigned char *buf, ulong len)
 	return cmagic->comp_id;
 }
 
+#if !defined(USE_HOSTCC)
+void *__weak image_get_decomp_buf(void *load_buf)
+{
+	return load_buf;
+}
+
+void __weak image_decomp_flush(ulong load, ulong image_len)
+{
+}
+#endif
+
 int image_decomp(int comp, ulong load, ulong image_start, int type,
 		 void *load_buf, void *image_buf, ulong image_len,
 		 uint unc_len, ulong *load_end)
 {
 	int ret = -ENOSYS;
+	void *dst = load_buf;
 
 	*load_end = load;
 	print_decomp_msg(comp, type, load == image_start, load);
 
+#if !defined(USE_HOSTCC)
+	dst = image_get_decomp_buf(load_buf);
+#endif
+
 	/*
 	 * Load the image to the right place, decompressing if needed. After
 	 * this, image_len will be set to the number of uncompressed bytes
@@ -462,13 +478,13 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
 		if (load == image_start)
 			break;
 		if (image_len <= unc_len)
-			memmove_wd(load_buf, image_buf, image_len, CHUNKSZ);
+			memmove_wd(dst, image_buf, image_len, CHUNKSZ);
 		else
 			ret = -ENOSPC;
 		break;
 	case IH_COMP_GZIP:
 		if (!tools_build() && CONFIG_IS_ENABLED(GZIP))
-			ret = gunzip(load_buf, unc_len, image_buf, &image_len);
+			ret = gunzip(dst, unc_len, image_buf, &image_len);
 		break;
 	case IH_COMP_BZIP2:
 		if (!tools_build() && CONFIG_IS_ENABLED(BZIP2)) {
@@ -479,7 +495,7 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
 			 * use slower decompression algorithm which requires
 			 * at most 2300 KB of memory.
 			 */
-			ret = BZ2_bzBuffToBuffDecompress(load_buf, &size,
+			ret = BZ2_bzBuffToBuffDecompress(dst, &size,
 				image_buf, image_len, CONSERVE_MEMORY, 0);
 			image_len = size;
 		}
@@ -488,7 +504,7 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
 		if (!tools_build() && CONFIG_IS_ENABLED(LZMA)) {
 			SizeT lzma_len = unc_len;
 
-			ret = lzmaBuffToBuffDecompress(load_buf, &lzma_len,
+			ret = lzmaBuffToBuffDecompress(dst, &lzma_len,
 						       image_buf, image_len);
 			image_len = lzma_len;
 		}
@@ -497,7 +513,7 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
 		if (!tools_build() && CONFIG_IS_ENABLED(LZO)) {
 			size_t size = unc_len;
 
-			ret = lzop_decompress(image_buf, image_len, load_buf, &size);
+			ret = lzop_decompress(image_buf, image_len, dst, &size);
 			image_len = size;
 		}
 		break;
@@ -505,7 +521,7 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
 		if (!tools_build() && CONFIG_IS_ENABLED(LZ4)) {
 			size_t size = unc_len;
 
-			ret = ulz4fn(image_buf, image_len, load_buf, &size);
+			ret = ulz4fn(image_buf, image_len, dst, &size);
 			image_len = size;
 		}
 		break;
@@ -514,7 +530,7 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
 			struct abuf in, out;
 
 			abuf_init_set(&in, image_buf, image_len);
-			abuf_init_set(&out, load_buf, unc_len);
+			abuf_init_set(&out, dst, unc_len);
 			ret = zstd_decompress(&in, &out);
 			if (ret >= 0) {
 				image_len = ret;
@@ -532,6 +548,10 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
 	if (ret)
 		return ret;
 
+#if !defined(USE_HOSTCC)
+	image_decomp_flush(load, image_len);
+#endif
+
 	return 0;
 }
 
diff --git a/include/image.h b/include/image.h
index 34efac60..b2a6c536 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1014,6 +1014,11 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
 		 void *load_buf, void *image_buf, ulong image_len,
 		 uint unc_len, ulong *load_end);
 
+#ifndef USE_HOSTCC
+void *image_get_decomp_buf(void *load_buf);
+void image_decomp_flush(ulong load, ulong image_len);
+#endif
+
 /**
  * Set up properties in the FDT
  *
-- 
2.53.0


  parent reply	other threads:[~2026-08-25 22:50 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260825224330.713151-1-maskachoska.ref@yahoo.com>
2026-08-25 22:41 ` [PATCH v1 00/12] mips: add EcoNet/Airoha EN75xx (EN7512/EN7528) SoC support AK Sharma
2026-08-25 22:41   ` [PATCH v1 01/12] mips: en75xx: add EcoNet/Airoha EN75xx " AK Sharma
2026-08-25 22:41   ` [PATCH v1 02/12] mips: en75xx: add TPL and SPL early boot stages AK Sharma
2026-08-25 22:53     ` Tom Rini
2026-08-25 22:41   ` [PATCH v1 03/12] serial: en75xx: add EcoNet/Airoha EN75xx UART driver AK Sharma
2026-08-25 22:41   ` [PATCH v1 04/12] spi: airoha-snfi: add EN7528 SPI-NAND controller support AK Sharma
2026-08-25 22:42   ` [PATCH v1 05/12] mtd: spi-nand: add EN75 BMT bad-block management support AK Sharma
2026-08-25 22:59     ` Tom Rini
2026-08-26  6:47       ` Frieder Schrempf
2026-08-25 22:42   ` [PATCH v1 06/12] net: airoha-eth: add EN7528 Ethernet support AK Sharma
2026-08-25 22:42   ` [PATCH v1 07/12] mtd: env, cmd: add EN75 NAND remap handling AK Sharma
2026-08-25 23:06     ` Tom Rini
2026-08-25 22:42   ` AK Sharma [this message]
2026-08-25 23:05     ` [PATCH v1 08/12] boot: image: add weak hooks for the decompression buffer and flush Tom Rini
2026-08-25 22:42   ` [PATCH v1 09/12] mips: dts: add EcoNet EN75xx device trees AK Sharma
2026-08-25 22:55     ` Tom Rini
2026-08-25 22:42   ` [PATCH v1 10/12] board: econet: add EN7512 reference board AK Sharma
2026-08-25 22:42   ` [PATCH v1 11/12] board: econet: add EN7528 board support AK Sharma
2026-08-25 22:57     ` Tom Rini
2026-08-25 23:00     ` Tom Rini
2026-08-25 22:42   ` [PATCH v1 12/12] doc: board: econet: add EN75xx documentation AK Sharma
2026-08-25 23:02   ` [PATCH v1 00/12] mips: add EcoNet/Airoha EN75xx (EN7512/EN7528) SoC support Tom Rini
2026-08-26 14:26   ` Matheus Sampaio Queiroga
2026-08-26 15:05     ` Tom Rini
2026-08-26 15:16       ` AK Sharma
2026-08-26 15:17         ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260825224330.713151-9-maskachoska@yahoo.com \
    --to=maskachoska@yahoo.com \
    --cc=ansuelsmth@gmail.com \
    --cc=daniel.schwierzeck@gmail.com \
    --cc=dario.binacchi@amarulasolutions.com \
    --cc=frieder.schrempf@kontron.de \
    --cc=jerome.forissier@arm.com \
    --cc=marex@denx.de \
    --cc=michael@amarulasolutions.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.