Add basic support for mini2440 board to barebox.
[barebox-mini2440.git] / include / envfs.h
blobb5849d9b8dfeb4f5dca7873a77847e86333dc6ec
1 #ifndef _ENVFS_H
2 #define _ENVFS_H
4 #include <asm/byteorder.h>
6 #define ENVFS_MAGIC 0x798fba79 /* some random number */
7 #define ENVFS_INODE_MAGIC 0x67a8c78d
8 #define ENVFS_END_MAGIC 0x6a87d6cd
9 #define ENVFS_SIGNATURE "barebox envfs"
11 struct envfs_inode {
12 uint32_t magic; /* ENVFS_INODE_MAGIC */
13 uint32_t size; /* data size in bytes */
14 uint32_t namelen; /* The length of the filename _including_ a trailing 0 */
15 char data[0]; /* The filename (zero terminated) + padding to 4 byte boundary
16 * followed by the data for this inode.
17 * The next inode follows after the data + padding to 4 byte
18 * boundary.
23 * Superblock information at the beginning of the FS.
25 struct envfs_super {
26 uint32_t magic; /* ENVFS_MAGIC */
27 uint32_t priority;
28 uint32_t crc; /* crc for the data */
29 uint32_t size; /* size of data */
30 uint32_t flags; /* feature flags */
31 uint32_t future; /* reserved for future use */
32 uint32_t sb_crc; /* crc for the superblock */
35 #ifndef __BYTE_ORDER
36 #error "No byte order defined in __BYTE_ORDER"
37 #endif
39 #if __BYTE_ORDER == __LITTLE_ENDIAN
40 #define ENVFS_16(x) (x)
41 #define ENVFS_24(x) (x)
42 #define ENVFS_32(x) (x)
43 #define ENVFS_GET_NAMELEN(x) ((x)->namelen)
44 #define ENVFS_GET_OFFSET(x) ((x)->offset)
45 #define ENVFS_SET_OFFSET(x,y) ((x)->offset = (y))
46 #define ENVFS_SET_NAMELEN(x,y) ((x)->namelen = (y))
47 #elif __BYTE_ORDER == __BIG_ENDIAN
48 #ifdef __KERNEL__
49 #define ENVFS_16(x) swab16(x)
50 #define ENVFS_24(x) ((swab32(x)) >> 8)
51 #define ENVFS_32(x) swab32(x)
52 #else /* not __KERNEL__ */
53 #define ENVFS_16(x) bswap_16(x)
54 #define ENVFS_24(x) ((bswap_32(x)) >> 8)
55 #define ENVFS_32(x) bswap_32(x)
56 #endif /* not __KERNEL__ */
57 #define ENVFS_GET_NAMELEN(x) ENVFS_32(((x)->namelen))
58 #define ENVFS_GET_OFFSET(x) ENVFS_32(((x)->offset))
59 #define ENVFS_SET_NAMELEN(x,y)((x)->offset = ENVFS_32((y)))
60 #define ENVFS_SET_OFFSET(x,y) ((x)->namelen = ENVFS_32((y)))
61 #else
62 #error "__BYTE_ORDER must be __LITTLE_ENDIAN or __BIG_ENDIAN"
63 #endif
65 #endif /* _ENVFS_H */