kexec.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Arnaud Ferraris <arnaud.ferraris.external@sigfox.com>
To: horms@verge.net.au, kexec@lists.infradead.org
Subject: [PATCH 3/3] kexec: arm64: Add fitImage support
Date: Thu,  5 Jul 2018 14:55:35 +0200	[thread overview]
Message-ID: <1530795335-20867-4-git-send-email-arnaud.ferraris.external@sigfox.com> (raw)
In-Reply-To: <1530795335-20867-1-git-send-email-arnaud.ferraris.external@sigfox.com>

Signed-off-by: Arnaud Ferraris <arnaud.ferraris.external@sigfox.com>
---
 kexec/arch/arm64/Makefile               |  2 ++
 kexec/arch/arm64/kexec-arm64.c          | 15 +++++++++++--
 kexec/arch/arm64/kexec-arm64.h          |  4 ++++
 kexec/arch/arm64/kexec-fitImage-arm64.c | 40 +++++++++++++++++++++++++++++++++
 kexec/kexec.h                           |  4 ++++
 5 files changed, 63 insertions(+), 2 deletions(-)
 create mode 100644 kexec/arch/arm64/kexec-fitImage-arm64.c

diff --git a/kexec/arch/arm64/Makefile b/kexec/arch/arm64/Makefile
index 9d9111c..e33209e 100644
--- a/kexec/arch/arm64/Makefile
+++ b/kexec/arch/arm64/Makefile
@@ -15,9 +15,11 @@ arm64_KEXEC_SRCS += \
 	kexec/arch/arm64/kexec-arm64.c \
 	kexec/arch/arm64/kexec-elf-arm64.c \
 	kexec/arch/arm64/kexec-uImage-arm64.c \
+	kexec/arch/arm64/kexec-fitImage-arm64.c \
 	kexec/arch/arm64/kexec-image-arm64.c
 
 arm64_UIMAGE = kexec/kexec-uImage.c
+arm64_FITIMAGE = kexec/kexec-fitImage.c
 
 arm64_ARCH_REUSE_INITRD =
 arm64_ADD_SEGMENT =
diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
index 7a12479..344037c 100644
--- a/kexec/arch/arm64/kexec-arm64.c
+++ b/kexec/arch/arm64/kexec-arm64.c
@@ -55,6 +55,8 @@ struct file_type file_type[] = {
 	{"vmlinux", elf_arm64_probe, elf_arm64_load, elf_arm64_usage},
 	{"Image", image_arm64_probe, image_arm64_load, image_arm64_usage},
 	{"uImage", uImage_arm64_probe, uImage_arm64_load, uImage_arm64_usage},
+	{"fitImage", fitImage_arm64_probe, fitImage_arm64_load,
+		fitImage_arm64_usage},
 };
 
 int file_types = sizeof(file_type) / sizeof(file_type[0]);
@@ -613,6 +615,10 @@ int arm64_load_other_segments(struct kexec_info *info,
 	if (arm64_opts.dtb) {
 		dtb.name = "dtb_user";
 		dtb.buf = slurp_file(arm64_opts.dtb, &dtb.size);
+	} else if (info->dtb) {
+		dtb.name = "dtb_user";
+		dtb.buf = info->dtb;
+		dtb.size = info->dtb_size;
 	} else {
 		result = read_1st_dtb(&dtb);
 
@@ -637,8 +643,13 @@ int arm64_load_other_segments(struct kexec_info *info,
 	else
 		hole_max = ULONG_MAX;
 
-	if (arm64_opts.initrd) {
-		initrd_buf = slurp_file(arm64_opts.initrd, &initrd_size);
+	if (arm64_opts.initrd || info->initrd) {
+		if (arm64_opts.initrd)
+			initrd_buf = slurp_file(arm64_opts.initrd, &initrd_size);
+		else {
+			initrd_buf = info->initrd;
+			initrd_size = info->initrd_size;
+		}
 
 		if (!initrd_buf)
 			fprintf(stderr, "kexec: Empty ramdisk file.\n");
diff --git a/kexec/arch/arm64/kexec-arm64.h b/kexec/arch/arm64/kexec-arm64.h
index 22e4b69..cd05b0b 100644
--- a/kexec/arch/arm64/kexec-arm64.h
+++ b/kexec/arch/arm64/kexec-arm64.h
@@ -34,6 +34,10 @@ int uImage_arm64_probe(const char *buf, off_t len);
 int uImage_arm64_load(int argc, char **argv, const char *buf, off_t len,
 		      struct kexec_info *info);
 void uImage_arm64_usage(void);
+int fitImage_arm64_probe(const char *buf, off_t len);
+int fitImage_arm64_load(int argc, char **argv, const char *buf, off_t len,
+		      struct kexec_info *info);
+void fitImage_arm64_usage(void);
 
 off_t initrd_base;
 off_t initrd_size;
diff --git a/kexec/arch/arm64/kexec-fitImage-arm64.c b/kexec/arch/arm64/kexec-fitImage-arm64.c
new file mode 100644
index 0000000..1085f1b
--- /dev/null
+++ b/kexec/arch/arm64/kexec-fitImage-arm64.c
@@ -0,0 +1,40 @@
+/*
+ * fitImage support for ARM64
+ */
+
+#include <stdint.h>
+#include <string.h>
+#include <sys/types.h>
+#include <image.h>
+#include <kexec-fitImage.h>
+#include "../../kexec.h"
+#include "kexec-arm64.h"
+
+int fitImage_arm64_probe(const char *buf, off_t len)
+{
+	return fitImage_probe(buf, len, IH_ARCH_ARM64);
+}
+
+int fitImage_arm64_load(int argc, char **argv, const char *buf, off_t len,
+	struct kexec_info *info)
+{
+	struct FitImage_contents img;
+	int ret;
+
+	ret = fitImage_load(buf, len, &img);
+	if (ret)
+		return ret;
+
+	info->initrd = img.initrd;
+	info->initrd_size = img.initrd_size;
+	info->dtb = img.dtb;
+	info->dtb_size = img.dtb_size;
+
+	return image_arm64_load(argc, argv, img.kernel, img.kernel_size, info);
+}
+
+void fitImage_arm64_usage(void)
+{
+	printf(
+"     An ARM64 fitImage file, compressed or not, big or little endian.\n\n");
+}
diff --git a/kexec/kexec.h b/kexec/kexec.h
index a97b9ce..19a807a 100644
--- a/kexec/kexec.h
+++ b/kexec/kexec.h
@@ -166,6 +166,10 @@ struct kexec_info {
 	int initrd_fd;
 	char *command_line;
 	int command_line_len;
+	const char *initrd;
+	off_t initrd_size;
+	const char *dtb;
+	off_t dtb_size;
 
 	int skip_checks;
 };
-- 
2.7.4


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

  parent reply	other threads:[~2018-07-05 12:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-05 12:55 [PATCH 0/3] arm64: add support for loading kernel from FITimage Arnaud Ferraris
2018-07-05 12:55 ` [PATCH 1/3] kexec: Move zlib buffer decompression function Arnaud Ferraris
2018-07-05 12:55 ` [PATCH 2/3] kexec: fitImage: Add fitImage parser and loader Arnaud Ferraris
2018-07-05 12:55 ` Arnaud Ferraris [this message]
2018-07-06  6:37 ` [PATCH 0/3] arm64: add support for loading kernel from FITimage Bhupesh Sharma
2018-07-06 14:39   ` Arnaud Ferraris
2018-07-27  8:17     ` Arnaud Ferraris

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=1530795335-20867-4-git-send-email-arnaud.ferraris.external@sigfox.com \
    --to=arnaud.ferraris.external@sigfox.com \
    --cc=horms@verge.net.au \
    --cc=kexec@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;
as well as URLs for NNTP newsgroup(s).