Skip to contentSkip to conversation

kexec-arm: add uImage support

PATCH In review Marc Andre Tanner 3 participants 5 messages Nov 20, 2009 – Nov 27, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kexec-arm: add uImage support

uImages are basically just zImages with a special header, we therefore just skip the header and let the normal zImage infrastructure do the actual work.

---
 kexec/arch/arm/Makefile           |    2 +
 kexec/arch/arm/kexec-arm.c        |    3 +
 kexec/arch/arm/kexec-arm.h        |    4 +
 kexec/arch/arm/kexec-uImage-arm.c |   33 ++++++++
 kexec/arch/arm/kexec-uImage-arm.h |  161 +++++++++++++++++++++++++++++++++++++
 5 files changed, 203 insertions(+), 0 deletions(-)
 create mode 100644 kexec/arch/arm/kexec-uImage-arm.c
 create mode 100644 kexec/arch/arm/kexec-uImage-arm.h
kexec/arch/arm/Makefile +2 -0
index e05e4c7..806c4d9 100644
@@ -3,8 +3,10 @@
 #
 arm_KEXEC_SRCS=  kexec/arch/arm/kexec-elf-rel-arm.c
 arm_KEXEC_SRCS+= kexec/arch/arm/kexec-zImage-arm.c
+arm_KEXEC_SRCS+= kexec/arch/arm/kexec-uImage-arm.c
 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-arm.c +3 -0
index 2e50489..3fdf839 100644
@@ -74,6 +74,9 @@ int get_memory_ranges(struct memory_range **range, int *ranges,
 
 /* Supported file types and callbacks */
 struct file_type file_type[] = {
+	/* uImage is probed before zImage because the latter also accepts
+	   uncompressed images. */
+	{"uImage", uImage_arm_probe, uImage_arm_load, zImage_arm_usage},
 	{"zImage", zImage_arm_probe, zImage_arm_load, zImage_arm_usage},
 };
 int file_types = sizeof(file_type) / sizeof(file_type[0]);
kexec/arch/arm/kexec-arm.h +4 -0
index bb41ce0..0d9a066 100644
@@ -6,4 +6,8 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 		        struct kexec_info *info);
 void zImage_arm_usage(void);
 
+int uImage_arm_probe(const char *buf, off_t len);
+int uImage_arm_load(int argc, char **argv, const char *buf, off_t len,
+		        struct kexec_info *info);
+
 #endif /* KEXEC_ARM_H */
kexec/arch/arm/kexec-uImage-arm.c new file +33 -0
new file mode 100644
index 0000000..44c8d5f
@@ -0,0 +1,33 @@
+/*
+ * uImage support added by Marc Andre Tanner <[email protected]>
+ */
+#include <stdint.h>
+#include <string.h>
+#include <sys/types.h>
+#include "../../kexec.h"
+#include "kexec-arm.h"
+#include "kexec-uImage-arm.h"
+
+int uImage_arm_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_arm_load(int argc, char **argv, const char *buf, off_t len,
+	struct kexec_info *info)
+{
+	return zImage_arm_load(argc, argv, buf + sizeof(struct image_header),
+	                       len - sizeof(struct image_header), info);
+}
kexec/arch/arm/kexec-uImage-arm.h new file +161 -0

161 lines not on this page · raw message

Signature · 7 lines
1.6.5


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw
Quoted 3 lines · Marc Andre Tanner

uImages are basically just zImages with a special header, we therefore just skip the header and let the normal zImage infrastructure do the actual work.

This looks entirely reasonable to me.
Unless someone jumps in and comments
in the next few days I'll apply it.

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

#2 lore raw
Quoted 8 lines · Simon Horman
Quoted 3 lines · Marc Andre Tanner

uImages are basically just zImages with a special header, we therefore just skip the header and let the normal zImage infrastructure do the actual work.

This looks entirely reasonable to me.
Unless someone jumps in and comments
in the next few days I'll apply it.

I've gone ahead an applied this change.

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

#3 lore raw
Quoted 11 lines · Simon Horman
Quoted 8 lines · Simon Horman
Quoted 3 lines · Marc Andre Tanner

uImages are basically just zImages with a special header, we therefore just skip the header and let the normal zImage infrastructure do the actual work.

This looks entirely reasonable to me.
Unless someone jumps in and comments
in the next few days I'll apply it.

I've gone ahead an applied this change.

Thanks,
Marc

Signature · 6 lines
 Marc Andre Tanner >< http://www.brain-dump.org/ >< GPG key: CF7D56C0

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