From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/7] ARM: Layerscape: add bootm handler for images
Date: Thu, 12 Sep 2019 12:29:00 +0200 [thread overview]
Message-ID: <20190912102905.21307-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20190912102905.21307-1-a.fatoum@pengutronix.de>
The layerscape images are preceeded by a RCW and PBI, which are interpreted
by the Layerscape Hardware Pre-Bootloader and aren't executable as ARM code.
To maintain the ability to network boot them, add a bootm handler that
skips the fixed-size header.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/mach-layerscape/Makefile | 1 +
arch/arm/mach-layerscape/pblimage.c | 46 +++++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
create mode 100644 arch/arm/mach-layerscape/pblimage.c
diff --git a/arch/arm/mach-layerscape/Makefile b/arch/arm/mach-layerscape/Makefile
index 8a814f944161..854a327c9125 100644
--- a/arch/arm/mach-layerscape/Makefile
+++ b/arch/arm/mach-layerscape/Makefile
@@ -5,3 +5,4 @@ obj-y += icid.o
obj-pbl-y += boot.o
pbl-y += xload-qspi.o xload.o
obj-$(CONFIG_ARCH_LAYERSCAPE_PPA) += ppa.o ppa-entry.o
+obj-$(CONFIG_BOOTM) += pblimage.o
diff --git a/arch/arm/mach-layerscape/pblimage.c b/arch/arm/mach-layerscape/pblimage.c
new file mode 100644
index 000000000000..74a4c805bc67
--- /dev/null
+++ b/arch/arm/mach-layerscape/pblimage.c
@@ -0,0 +1,46 @@
+#include <bootm.h>
+#include <common.h>
+#include <init.h>
+#include <libfile.h>
+#include <linux/sizes.h>
+
+#define BAREBOX_STAGE2_OFFSET SZ_128K
+
+static int do_bootm_layerscape_pblimage(struct image_data *pbl_data)
+{
+ int ret;
+ char pblimage_filename[] = "/.layerscape-pbl.img";
+ struct bootm_data bb_data = {
+ .initrd_address = UIMAGE_INVALID_ADDRESS,
+ .os_address = UIMAGE_SOME_ADDRESS,
+ .os_file = pblimage_filename,
+ };
+
+ ret = copy_file_2(pbl_data->os_file, bb_data.os_file,
+ BAREBOX_STAGE2_OFFSET, 0);
+ if (ret)
+ return ret;
+
+ return bootm_boot(&bb_data);
+}
+
+static struct image_handler image_handler_layerscape_pbl_image = {
+ .name = "Layerscape image",
+ .bootm = do_bootm_layerscape_pblimage,
+ .filetype = filetype_layerscape_image,
+};
+
+static struct image_handler image_handler_layerscape_qspi_pbl_image = {
+ .name = "Layerscape QSPI image",
+ .bootm = do_bootm_layerscape_pblimage,
+ .filetype = filetype_layerscape_qspi_image,
+};
+
+static int layerscape_register_pbl_image_handler(void)
+{
+ register_image_handler(&image_handler_layerscape_pbl_image);
+ register_image_handler(&image_handler_layerscape_qspi_pbl_image);
+
+ return 0;
+}
+late_initcall(layerscape_register_pbl_image_handler);
--
2.23.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2019-09-12 10:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-12 10:28 [PATCH 1/7] libfile: introduce copy_file_2 for copying starting with offset Ahmad Fatoum
2019-09-12 10:29 ` Ahmad Fatoum [this message]
2019-09-12 10:29 ` [PATCH 3/7] ARM: Layerscape: don't generate second-stage 2nd.image Ahmad Fatoum
2019-09-12 10:29 ` [PATCH 4/7] filetype: support fastboot barebox_update with layerscape image Ahmad Fatoum
2019-09-12 10:29 ` [PATCH 5/7] scripts: pblimage: explicitly set architecture to ARM Ahmad Fatoum
2019-09-13 14:38 ` Roland Hieber
2019-09-12 10:29 ` [PATCH 6/7] ARM: layerscape: tqmls1046a: disable all SGMII PHYs Ahmad Fatoum
2019-09-12 10:29 ` [PATCH 7/7] Documentation: boards: document layerscape support Ahmad Fatoum
2019-09-12 13:06 ` [PATCH 1/7] libfile: introduce copy_file_2 for copying starting with offset Uwe Kleine-König
2019-09-12 13:37 ` Ahmad Fatoum
2019-09-12 14:30 ` Sascha Hauer
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=20190912102905.21307-2-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox