public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de, Stefano Babic <sbabic@denx.de>
Cc: Tim Harvey <tharvey@gateworks.com>, Heiko Schocher <hs@denx.de>,
	Fabio Estevam <festevam@gmail.com>,
	"NXP i.MX U-Boot Team" <uboot-imx@nxp.com>
Subject: [PATCH v1 2/2] imx: spl: implement spl_load_simple_fit_fix_load
Date: Fri,  6 Aug 2021 06:44:27 +0200	[thread overview]
Message-ID: <20210806044427.1958686-3-hs@denx.de> (raw)
In-Reply-To: <20210806044427.1958686-1-hs@denx.de>

read the address where the IVT header must sit
from IVT image header, loaded from SPL into
an malloced buffer and copy the IVT header
to this address

May make this dependend on SoC ?

Signed-off-by: Heiko Schocher <hs@denx.de>
---

 arch/arm/mach-imx/spl.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
index 36033d611c..cc29f337d7 100644
--- a/arch/arm/mach-imx/spl.c
+++ b/arch/arm/mach-imx/spl.c
@@ -345,3 +345,36 @@ int dram_init_banksize(void)
 	return 0;
 }
 #endif
+
+/*
+ * read the address where the IVT header must sit
+ * from IVT image header, loaded from SPL into
+ * an malloced buffer and copy the IVT header
+ * to this address
+ */
+void *spl_load_simple_fit_fix_load(void *fit)
+{
+	struct ivt *ivt;
+	unsigned long new;
+	unsigned long offset;
+	unsigned long size;
+	u8 *tmp = (u8 *)fit;
+
+	offset = ALIGN(fdt_totalsize(fit), 0x1000);
+	size = ALIGN(fdt_totalsize(fit), 4);
+	size = board_spl_fit_size_align(size);
+	tmp += offset;
+	ivt = (struct ivt *)tmp;
+	if (ivt->hdr.magic != IVT_HEADER_MAGIC) {
+		debug("no IVT header found\n");
+		return fit;
+	}
+	debug("%s: ivt: %p offset: %lx size: %lx\n", __func__, ivt, offset, size);
+	debug("%s: ivt self: %x\n", __func__, ivt->self);
+	new = ivt->self;
+	new -= offset;
+	debug("%s: new %lx\n", __func__, new);
+	memcpy((void *)new, fit, size);
+
+	return (void *)new;
+}
-- 
2.31.1


  parent reply	other threads:[~2021-08-06  4:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-06  4:44 [PATCH v1 0/2] imx8m: fix secure boot Heiko Schocher
2021-08-06  4:44 ` [PATCH v1 1/2] spl_fit. add hook to make fixes after fit header is loaded Heiko Schocher
2021-09-30  4:09   ` Simon Glass
2021-10-07 14:13   ` sbabic
2021-08-06  4:44 ` Heiko Schocher [this message]
2021-10-07 14:12   ` [PATCH v1 2/2] imx: spl: implement spl_load_simple_fit_fix_load sbabic
2021-08-06  5:56 ` [PATCH v1 0/2] imx8m: fix secure boot Peng Fan (OSS)
2021-08-06  6:39   ` Heiko Schocher
2021-08-06  7:16     ` [EXT] " Ye Li

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=20210806044427.1958686-3-hs@denx.de \
    --to=hs@denx.de \
    --cc=festevam@gmail.com \
    --cc=sbabic@denx.de \
    --cc=tharvey@gateworks.com \
    --cc=u-boot@lists.denx.de \
    --cc=uboot-imx@nxp.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox