summaryrefslogtreecommitdiffstats
path: root/include/envfs.h
diff options
context:
space:
mode:
authorCarsten Schlote <c.schlote@konzeptpark.de>2008-02-15 13:40:30 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2008-02-19 08:56:01 +0100
commitdb291de28014807ab0e8c97cbadf381c3d781f2d (patch)
tree46974f92145f17b4a5b8656a19b860c66abb9e8f /include/envfs.h
parentea65ad15bae287b6b7ea7b68ed30cb3d29be55b5 (diff)
downloadbarebox-db291de28014807ab0e8c97cbadf381c3d781f2d.tar.gz
barebox-db291de28014807ab0e8c97cbadf381c3d781f2d.tar.xz
[general] Fixed endian handling for envfs
Fixed the handling of data similiar as found in cramfs. This fixes the problem with an unreadable defaultenv on big-endian targets. The endian macors are now loaded from /asm/common.h by default. Signed-off-by: Carsten Schlote <c.schlote@konzeptpark.de>
Diffstat (limited to 'include/envfs.h')
-rw-r--r--include/envfs.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/include/envfs.h b/include/envfs.h
index 6f12342834..406bc61e75 100644
--- a/include/envfs.h
+++ b/include/envfs.h
@@ -1,7 +1,7 @@
#ifndef _ENVFS_H
#define _ENVFS_H
-#define ENVFS_MAGIC 0x798fba79 /* some random number */
+#define ENVFS_MAGIC 0x798fba79 /* some random number */
#define ENVFS_INODE_MAGIC 0x67a8c78d
#define ENVFS_END_MAGIC 0x6a87d6cd
#define ENVFS_SIGNATURE "U-Boot envfs"
@@ -30,7 +30,12 @@ struct envfs_super {
uint32_t sb_crc; /* crc for the superblock */
};
+#ifndef __BYTE_ORDER
+#error "No byte order defined in __BYTE_ORDER"
+#endif
+
#if __BYTE_ORDER == __LITTLE_ENDIAN
+#warning "envfs compiled on little endian host"
#define ENVFS_16(x) (x)
#define ENVFS_24(x) (x)
#define ENVFS_32(x) (x)
@@ -39,6 +44,7 @@ struct envfs_super {
#define ENVFS_SET_OFFSET(x,y) ((x)->offset = (y))
#define ENVFS_SET_NAMELEN(x,y) ((x)->namelen = (y))
#elif __BYTE_ORDER == __BIG_ENDIAN
+#warning "envfs compiled on big endian host"
#ifdef __KERNEL__
#define ENVFS_16(x) swab16(x)
#define ENVFS_24(x) ((swab32(x)) >> 8)
@@ -48,6 +54,16 @@ struct envfs_super {
#define ENVFS_24(x) ((bswap_32(x)) >> 8)
#define ENVFS_32(x) bswap_32(x)
#endif /* not __KERNEL__ */
+#define CRAMFS_GET_NAMELEN(x) (((u8*)(x))[8] & 0x3f)
+#define CRAMFS_GET_OFFSET(x) ((CRAMFS_24(((u32*)(x))[2] & 0xffffff) << 2) |\
+ ((((u32*)(x))[2] & 0xc0000000) >> 30))
+#define CRAMFS_SET_NAMELEN(x,y) (((u8*)(x))[8] = (((0x3f & (y))) | \
+ (0xc0 & ((u8*)(x))[8])))
+#define CRAMFS_SET_OFFSET(x,y) (((u32*)(x))[2] = (((y) & 3) << 30) | \
+ CRAMFS_24((((y) & 0x03ffffff) >> 2)) | \
+ (((u32)(((u8*)(x))[8] & 0x3f)) << 24))
+#else
+#error "__BYTE_ORDER must be __LITTLE_ENDIAN or __BIG_ENDIAN"
#endif
#endif /* _ENVFS_H */