[PATCH 01/10] filetype: add is_barebox_mips_head support
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Tue Jan 22 09:40:36 EST 2013
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
common/filetype.c | 2 +-
include/filetype.h | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/common/filetype.c b/common/filetype.c
index 748e364..bafdc31 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -145,7 +145,7 @@ enum filetype file_detect_type(void *_buf, size_t bufsize)
return filetype_aimage;
if (buf64[0] == le64_to_cpu(0x0a1a0a0d474e5089ull))
return filetype_png;
- if (strncmp(buf8 + 0x10, "barebox", 7) == 0)
+ if (is_barebox_mips_head(_buf))
return filetype_mips_barebox;
if (bufsize < 64)
diff --git a/include/filetype.h b/include/filetype.h
index 91139db..c2af917 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -50,4 +50,20 @@ static inline int is_barebox_arm_head(const char *head)
}
#endif
+#define MIPS_HEAD_SIZE 0x20
+#define MIPS_HEAD_MAGICWORD_OFFSET 0x10
+#define MIPS_HEAD_SIZE_OFFSET 0x1C
+
+#ifdef CONFIG_MIPS
+static inline int is_barebox_mips_head(const char *head)
+{
+ return !strcmp(head + MIPS_HEAD_MAGICWORD_OFFSET, "barebox");
+}
+#else
+static inline int is_barebox_mips_head(const char *head)
+{
+ return 0;
+}
+#endif
+
#endif /* __FILE_TYPE_H */
--
1.7.10.4
More information about the barebox
mailing list