summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2009-12-16 16:02:49 +0900
committerPaul Mundt <lethal@linux-sh.org>2009-12-16 16:02:49 +0900
commit1875419755e36ac49c53c166c033ed5c181287b6 (patch)
treeaed582b8cb33221d573e19ff89396a394606120a
parentd1faa4cbb9d771daaf624cfd016f5517b21d9dc9 (diff)
kexec-sh: uImage support.
This follows the ARM change, and wires up uImage support on SH, with all of the same caveats. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r--kexec/arch/sh/Makefile1
-rw-r--r--kexec/arch/sh/kexec-sh.c9
-rw-r--r--kexec/arch/sh/kexec-sh.h4
-rw-r--r--kexec/arch/sh/kexec-uImage-sh.c35
4 files changed, 46 insertions, 3 deletions
diff --git a/kexec/arch/sh/Makefile b/kexec/arch/sh/Makefile
index 6e53626..9ccd008 100644
--- a/kexec/arch/sh/Makefile
+++ b/kexec/arch/sh/Makefile
@@ -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
diff --git a/kexec/arch/sh/kexec-sh.c b/kexec/arch/sh/kexec-sh.c
index 141ea8b..d04989d 100644
--- a/kexec/arch/sh/kexec-sh.c
+++ b/kexec/arch/sh/kexec-sh.c
@@ -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]);
diff --git a/kexec/arch/sh/kexec-sh.h b/kexec/arch/sh/kexec-sh.h
index 3b46a47..2d50af6 100644
--- a/kexec/arch/sh/kexec-sh.h
+++ b/kexec/arch/sh/kexec-sh.h
@@ -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);
diff --git a/kexec/arch/sh/kexec-uImage-sh.c b/kexec/arch/sh/kexec-uImage-sh.c
new file mode 100644
index 0000000..869bbd4
--- /dev/null
+++ b/kexec/arch/sh/kexec-uImage-sh.c
@@ -0,0 +1,35 @@
+/*
+ * uImage support added by Marc Andre Tanner <mat@brain-dump.org>
+ *
+ * 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);
+}