mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Lucas Stach <dev@lynxeye.de>
To: barebox@lists.infradead.org
Subject: [PATCH 4/4] ARM: zynq: add Zynq image bootm handler
Date: Tue, 10 Dec 2019 23:03:22 +0100	[thread overview]
Message-ID: <20191210220322.47425-4-dev@lynxeye.de> (raw)
In-Reply-To: <20191210220322.47425-1-dev@lynxeye.de>

This adds a bootm handler for the Zynq image, to allow second
stage booting of a unchanged Zynq boot image.

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 arch/arm/mach-zynq/Makefile        |  2 +-
 arch/arm/mach-zynq/bootm-zynqimg.c | 49 ++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-zynq/bootm-zynqimg.c

diff --git a/arch/arm/mach-zynq/Makefile b/arch/arm/mach-zynq/Makefile
index 3252247d176d..c88ab4666f0f 100644
--- a/arch/arm/mach-zynq/Makefile
+++ b/arch/arm/mach-zynq/Makefile
@@ -1 +1 @@
-obj-y += zynq.o
+obj-y += zynq.o bootm-zynqimg.o
diff --git a/arch/arm/mach-zynq/bootm-zynqimg.c b/arch/arm/mach-zynq/bootm-zynqimg.c
new file mode 100644
index 000000000000..e903ab667905
--- /dev/null
+++ b/arch/arm/mach-zynq/bootm-zynqimg.c
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <bootm.h>
+#include <common.h>
+#include <init.h>
+#include <memory.h>
+
+static int do_bootm_zynqimage(struct image_data *data)
+{
+	resource_size_t start, end;
+	void (*barebox)(void);
+	u32 *header;
+	int ret;
+
+	ret = memory_bank_first_find_space(&start, &end);
+	if (ret)
+		return ret;
+
+	ret = bootm_load_os(data, start);
+	if (ret)
+		return ret;
+
+	header = (u32*)start;
+	barebox = (void*)start + header[12];
+
+	if (data->verbose)
+		printf("Loaded barebox image to 0x%08lx\n",
+		       (unsigned long)barebox);
+
+	shutdown_barebox();
+
+	barebox();
+
+	return -EIO;
+}
+
+static struct image_handler zynq_image_handler = {
+	.name = "Zynq image",
+	.bootm = do_bootm_zynqimage,
+	.filetype = filetype_zynq_image,
+};
+
+static int zynq_register_image_handler(void)
+{
+	register_image_handler(&zynq_image_handler);
+
+	return 0;
+}
+late_initcall(zynq_register_image_handler);
-- 
2.23.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2019-12-10 22:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-10 22:03 [PATCH 1/4] ARM: zynq: zedboard: split out PS7 init Lucas Stach
2019-12-10 22:03 ` [PATCH 2/4] ARM: zynq: zedboard: allow lowlevel init to be called as second stage Lucas Stach
2019-12-10 22:03 ` [PATCH 3/4] filetype: add Zynq image type Lucas Stach
2019-12-10 22:03 ` Lucas Stach [this message]
2019-12-11  8:52 ` [PATCH 1/4] ARM: zynq: zedboard: split out PS7 init 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=20191210220322.47425-4-dev@lynxeye.de \
    --to=dev@lynxeye.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