Skip to contentSkip to conversation

kexec: uImage tidying and SH support.

PATCH In review Paul Mundt 2 participants 2 messages Dec 16, 2009

Subsystems (2)
lore
Share & tools
lore

Paul Mundt

author
#0 lore raw

PATCH 1/1 kexec: uImage tidying and SH support.

Here is a trivial patch series for tidying up the uImage support a bit as well as wiring it up on SH. Nothing terribly exciting, just a bit of refactoring and updating. In addition to testing on SH, it's also been compile tested on ARM, which at present is the only other platform that makes use of this code.

The patch series can be pulled directly from:

git://github.com/pmundt/kexec-tools-sh.git sh/uImage

Which contains:

Paul Mundt (3):
kexec: Move the uImage header to a better place.
kexec: Bring the uImage definitions in sync with upstream.
kexec-sh: uImage support.

 include/Makefile                                   |    1 +
 .../arch/arm/kexec-uImage-arm.h => include/image.h |   41 ++++++++++---------
 kexec/arch/arm/Makefile                            |    1 -
 kexec/arch/arm/kexec-uImage-arm.c                  |    2 +-
 kexec/arch/sh/Makefile                             |    1 +
 kexec/arch/sh/kexec-sh.c                           |    9 +++-
 kexec/arch/sh/kexec-sh.h                           |    4 ++
 kexec/arch/sh/kexec-uImage-sh.c                    |   35 +++++++++++++++++
 8 files changed, 70 insertions(+), 24 deletions(-)
 rename kexec/arch/arm/kexec-uImage-arm.h => include/image.h (85%)
 create mode 100644 kexec/arch/sh/kexec-uImage-sh.c

---

And here is the patch, for reference.

include/Makefile +1 -0
index bf2c4ed..de5a3bb 100644
@@ -5,6 +5,7 @@ dist += include/Makefile		\
 	include/x86/mb_info.h		\
 	include/x86/mb_header.h		\
 	include/elf.h			\
+	include/image.h			\
 	include/boot/linuxbios_tables.h	\
 	include/boot/beoboot.h		\
 	include/boot/elf_boot.h
include/image.h new file +164 -0

164 lines not on this page · raw message

kexec/arch/arm/Makefile +0 -1
index 806c4d9..9416339 100644
@@ -8,5 +8,4 @@ arm_KEXEC_SRCS+= kexec/arch/arm/kexec-arm.c
 
 dist += kexec/arch/arm/Makefile $(arm_KEXEC_SRCS)			\
 	kexec/arch/arm/kexec-arm.h					\
-	kexec/arch/arm/kexec-uImage-arm.h				\
 	kexec/arch/arm/include/arch/options.h
kexec/arch/arm/kexec-uImage-arm.c +1 -1
index 44c8d5f..2291aae 100644
@@ -4,9 +4,9 @@
 #include <stdint.h>
 #include <string.h>
 #include <sys/types.h>
+#include <image.h>
 #include "../../kexec.h"
 #include "kexec-arm.h"
-#include "kexec-uImage-arm.h"
 
 int uImage_arm_probe(const char *buf, off_t len)
 {
kexec/arch/arm/kexec-uImage-arm.h deleted +0 -161

161 lines not on this page · raw message

kexec/arch/sh/Makefile +1 -0
index 6e53626..9ccd008 100644
@@ -2,6 +2,7 @@
 # kexec sh (linux booting linux)
 #
 sh_KEXEC_SRCS += kexec/arch/sh/kexec-sh.c
+sh_KEXEC_SRCS += kexec/arch/sh/kexec-uImage-sh.c
 sh_KEXEC_SRCS += kexec/arch/sh/kexec-zImage-sh.c
 sh_KEXEC_SRCS += kexec/arch/sh/kexec-netbsd-sh.c
 sh_KEXEC_SRCS += kexec/arch/sh/kexec-elf-sh.c
kexec/arch/sh/kexec-sh.c +6 -3
index 141ea8b..d04989d 100644
@@ -73,9 +73,12 @@ int get_memory_ranges(struct memory_range **range, int *ranges,
 
 /* Supported file types and callbacks */
 struct file_type file_type[] = {
-       {"zImage-sh", zImage_sh_probe, zImage_sh_load, zImage_sh_usage},
-       {"elf-sh", elf_sh_probe, elf_sh_load, elf_sh_usage},
-       {"netbsd-sh", netbsd_sh_probe, netbsd_sh_load, netbsd_sh_usage},
+	/* uImage is probed before zImage because the latter also accepts
+	   uncompressed images. */
+	{ "uImage-sh", uImage_sh_probe, uImage_sh_load, zImage_sh_usage },
+	{ "zImage-sh", zImage_sh_probe, zImage_sh_load, zImage_sh_usage },
+	{ "elf-sh", elf_sh_probe, elf_sh_load, elf_sh_usage },
+	{ "netbsd-sh", netbsd_sh_probe, netbsd_sh_load, netbsd_sh_usage },
 };
 int file_types = sizeof(file_type) / sizeof(file_type[0]);
 
kexec/arch/sh/kexec-sh.h +4 -0
index 3b46a47..2d50af6 100644
@@ -3,6 +3,10 @@
 
 #define COMMAND_LINE_SIZE 2048
 
+int uImage_sh_probe(const char *buf, off_t len);
+int uImage_sh_load(int argc, char **argv, const char *buf, off_t len,
+		        struct kexec_info *info);
+
 int zImage_sh_probe(const char *buf, off_t len);
 int zImage_sh_load(int argc, char **argv, const char *buf, off_t len,
 	struct kexec_info *info);
kexec/arch/sh/kexec-uImage-sh.c new file +35 -0
new file mode 100644
index 0000000..869bbd4
@@ -0,0 +1,35 @@
+/*
+ * uImage support added by Marc Andre Tanner <[email protected]>
+ *
+ * Cloned from ARM by Paul Mundt, 2009.
+ */
+#include <stdint.h>
+#include <string.h>
+#include <sys/types.h>
+#include <image.h>
+#include "../../kexec.h"
+#include "kexec-sh.h"
+
+int uImage_sh_probe(const char *buf, off_t len)
+{
+	struct image_header header;
+
+	if (len < sizeof(header))
+		return -1;
+
+	memcpy(&header, buf, sizeof(header));
+
+	if (cpu_to_be32(header.ih_magic) != IH_MAGIC)
+		return -1;
+
+	/* XXX: check CRC Checksum? */
+
+	return 0;
+}
+
+int uImage_sh_load(int argc, char **argv, const char *buf, off_t len,
+	struct kexec_info *info)
+{
+	return zImage_sh_load(argc, argv, buf + sizeof(struct image_header),
+			      len - sizeof(struct image_header), info);
+}

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#1 lore raw
Quoted 8 lines · Paul Mundt

Here is a trivial patch series for tidying up the uImage support a bit as well as wiring it up on SH. Nothing terribly exciting, just a bit of refactoring and updating. In addition to testing on SH, it's also been compile tested on ARM, which at present is the only other platform that makes use of this code.

The patch series can be pulled directly from:

Quoted 8 lines

git://github.com/pmundt/kexec-tools-sh.git sh/uImage

Which contains:

Paul Mundt (3):
kexec: Move the uImage header to a better place.
kexec: Bring the uImage definitions in sync with upstream.
kexec-sh: uImage support.

Thanks Paul, pulled and pushed up to kernel.org.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec