#include <asm/types.h>
#include <mtd/mtd-user.h>
#include <mtd/inftl-user.h>
-
-#define swab16(x) \
- ((__u16)( \
- (((__u16)(x) & (__u16)0x00ffU) << 8) | \
- (((__u16)(x) & (__u16)0xff00U) >> 8) ))
-#define swab32(x) \
- ((__u32)( \
- (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \
- (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \
- (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \
- (((__u32)(x) & (__u32)0xff000000UL) >> 24) ))
-
-#if __BYTE_ORDER == __BIG_ENDIAN
-#define cpu_to_le16(x) ({ __u16 _x = x; swab16(_x); })
-#define cpu_to_le32(x) ({ __u32 _x = x; swab32(_x); })
-#else
-#define cpu_to_le16(x) (x)
-#define cpu_to_le32(x) (x)
-#endif
-#define le32_to_cpu(x) cpu_to_le32(x)
-#define le16_to_cpu(x) cpu_to_le16(x)
+#include <mtd_swab.h>
unsigned char *buf;
--- /dev/null
+#ifndef MTD_SWAB_H
+#define MTD_SWAB_H
+
+#include <endian.h>
+
+#define swab16(x) \
+ ((__u16)( \
+ (((__u16)(x) & (__u16)0x00ffU) << 8) | \
+ (((__u16)(x) & (__u16)0xff00U) >> 8) ))
+#define swab32(x) \
+ ((__u32)( \
+ (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \
+ (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \
+ (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \
+ (((__u32)(x) & (__u32)0xff000000UL) >> 24) ))
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define cpu_to_le16(x) ({ __u16 _x = x; swab16(_x); })
+#define cpu_to_le32(x) ({ __u32 _x = x; swab32(_x); })
+#define cpu_to_be16(x) (x)
+#define cpu_to_be32(x) (x)
+#else
+#define cpu_to_le16(x) (x)
+#define cpu_to_le32(x) (x)
+#define cpu_to_be16(x) ({ __u16 _x = x; swab16(_x); })
+#define cpu_to_be32(x) ({ __u32 _x = x; swab32(_x); })
+#endif
+#define le16_to_cpu(x) cpu_to_le16(x)
+#define be16_to_cpu(x) cpu_to_be16(x)
+#define le32_to_cpu(x) cpu_to_le32(x)
+#define be32_to_cpu(x) cpu_to_be32(x)
+
+#endif
#include <dirent.h>
#include <unistd.h>
#include <linux/types.h>
-#include <asm/byteorder.h>
+#include <mtd_swab.h>
#include <ctype.h>
-#define swab16(x) \
- ((__u16)( \
- (((__u16)(x) & (__u16)0x00ffU) << 8) | \
- (((__u16)(x) & (__u16)0xff00U) >> 8) ))
-#define swab32(x) \
- ((__u32)( \
- (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \
- (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \
- (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \
- (((__u32)(x) & (__u32)0xff000000UL) >> 24) ))
-
-#if __BYTE_ORDER == __BIG_ENDIAN
-#define cpu_to_le16(x) ({ __u16 _x = x; swab16(_x); })
-#define cpu_to_le32(x) ({ __u32 _x = x; swab32(_x); })
-#define cpu_to_be16(x) (x)
-#define cpu_to_be32(x) (x)
-#else
-#define cpu_to_le16(x) (x)
-#define cpu_to_le32(x) (x)
-#define cpu_to_be16(x) ({ __u16 _x = x; swab16(_x); })
-#define cpu_to_be32(x) ({ __u32 _x = x; swab32(_x); })
-#endif
-#define le32_to_cpu(x) cpu_to_le32(x)
-#define be32_to_cpu(x) cpu_to_be32(x)
#define BLOCK_SIZE 1024
#define JFFS_MAGIC 0x34383931 /* "1984" */
#include <mtd/mtd-user.h>
#include <mtd/nftl-user.h>
#include <mtd/inftl-user.h>
-
-#define swab16(x) \
- ((__u16)( \
- (((__u16)(x) & (__u16)0x00ffU) << 8) | \
- (((__u16)(x) & (__u16)0xff00U) >> 8) ))
-#define swab32(x) \
- ((__u32)( \
- (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \
- (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \
- (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \
- (((__u32)(x) & (__u32)0xff000000UL) >> 24) ))
-
-#if __BYTE_ORDER == __BIG_ENDIAN
-#define cpu_to_le16(x) ({ __u16 _x = x; swab16(_x); })
-#define cpu_to_le32(x) ({ __u32 _x = x; swab32(_x); })
-#else
-#define cpu_to_le16(x) (x)
-#define cpu_to_le32(x) (x)
-#endif
-#define le32_to_cpu(x) cpu_to_le32(x)
-#define le16_to_cpu(x) cpu_to_le16(x)
+#include <mtd_swab.h>
unsigned char BadUnitTable[MAX_ERASE_ZONES];
unsigned char *readbuf;
#include <asm/types.h>
#include <mtd/mtd-user.h>
#include <mtd/nftl-user.h>
+#include <mtd_swab.h>
static struct NFTLMediaHeader MedHead[2];
static mtd_info_t meminfo;
static unsigned char BadUnitTable[MAX_ERASE_ZONES];
-/* some byte swabbing stuff from include/linux/byteorder/ */
-#define swab16(x) \
- ((__u16)( \
- (((__u16)(x) & (__u16)0x00ffU) << 8) | \
- (((__u16)(x) & (__u16)0xff00U) >> 8) ))
-#define swab32(x) \
- ((__u32)( \
- (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \
- (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \
- (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \
- (((__u32)(x) & (__u32)0xff000000UL) >> 24) ))
-
#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define cpu_to_le16(x) (x)
-#define cpu_to_le32(x) (x)
#define SWAP16(x) do { ; } while(0)
#define SWAP32(x) do { ; } while(0)
#else
-#define cpu_to_le16(x) swab16(x)
-#define cpu_to_le32(x) swab32(x)
#define SWAP16(x) do { x = swab16(x); } while(0)
#define SWAP32(x) do { x = swab32(x); } while(0)
#endif
#include <mtd/mtd-user.h>
#include <linux/types.h>
-#include <asm/byteorder.h>
+#include <mtd_swab.h>
/* next is an array of mapping for each corresponding sector */
#define RFD_MAGIC 0x9193
return -1;
}
- if (__le16_to_cpu(rfd->header[0]) != RFD_MAGIC) {
+ if (le16_to_cpu(rfd->header[0]) != RFD_MAGIC) {
if (rfd->verbose)
printf("Block #%02d: Magic missing\n", block);
sectors = 0;
for (i=0; i<rfd->data_sectors; i++) {
- __u16 entry = __le16_to_cpu(rfd->header[i + HEADER_MAP_OFFSET]);
+ __u16 entry = le16_to_cpu(rfd->header[i + HEADER_MAP_OFFSET]);
if (entry == SECTOR_FREE || entry == SECTOR_DELETED)
continue;