CFLAGS+= -DCONFIG_YAFFS_USE_PTHREADS -lpthread
-COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o \
+COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o yaffs_hweight.o \
yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsfs.o yaffs_guts.o \
yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \
yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o yaffs_nand.o \
yaffsfs.h yaffs_osglue.h ydirectenv.h \
yaffs_flashif.c yaffscfg.h yaffs_list.h \
yaffs_qsort.c yportenv.h yaffs_attribs.c \
- yaffs_nandif.c yaffs_nandif.h yaffs_nandemul2k.h
+ yaffs_nandif.c yaffs_nandif.h yaffs_nandemul2k.h \
+ yaffs_hweight.h yaffs_hweight.c \
#CFLAGS+= -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline
-COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o \
+COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o yaffs_hweight.o\
yramsim.o yaffs_fileem2k.o\
yaffs_nandif.o yaffs_attribs.o \
yaffsfs.o yaffs_ecc.o yaffs_guts.o \
YAFFSDIRECTSYMLINKS = yaffsfs.c yaffsfs.h yaffscfg.h yaffs_osglue.h ydirectenv.h \
yaffs_flashif.c yaffs_flashif.h yaffs_flashif2.h yaffs_list.h \
yaffs_nandif.c yaffs_nandif.h yaffs_qsort.c yaffs_nandemul2k.h \
- yportenv.h yaffs_attribs.c
+ yportenv.h yaffs_attribs.c \
+ yaffs_hweight.c yaffs_hweight.h
DIRECTEXTRASYMLINKS = yaffscfg2k.c yaffs_fileem2k.c yaffs_fileem2k.h\
yaffs_fileem.c yaffs_norif1.c yaffs_norif1.h \
#CFLAGS+= -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline
-COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o \
+COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o yaffs_hweight.o\
yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsfs.o yaffs_guts.o \
yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \
yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o yaffs_nand.o \
yaffs_flashif.c yaffscfg.h yaffs_qsort.c \
yaffs_nandemul2k.h yaffs_list.h \
yaffs_attribs.c \
- yaffs_nandif.c yaffs_nandif.h yportenv.h
+ yaffs_nandif.c yaffs_nandif.h yportenv.h \
+ yaffs_hweight.c yaffs_hweight.h
DIRECTEXTRASYMLINKS = yaffscfg2k.c yaffs_fileem2k.c yaffs_fileem2k.h\
#CFLAGS+= -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline
-COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o \
+COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o yaffs_hweight.o \
yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsfs.o yaffs_guts.o \
yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \
yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o yaffs_nand.o \
yaffs_flashif.c yaffscfg.h yaffs_qsort.c \
yaffs_nandemul2k.h yaffs_list.h \
yaffs_attribs.c yaffs_osglue.h \
- yaffs_nandif.c yaffs_nandif.h yportenv.h
+ yaffs_nandif.c yaffs_nandif.h yportenv.h \
+ yaffs_hweight.h yaffs_hweight.c
DIRECTEXTRASYMLINKS = yaffscfg2k.c yaffs_fileem2k.c yaffs_fileem2k.h\
--- /dev/null
+/*
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ * for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+ /* These functions have been renamed to hweightxx to match the
+ * equivaqlent functions in the Linux kernel.
+ */
+
+#include "yaffs_hweight.h"
+
+static const char yaffs_count_bits_table[256] = {
+ 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
+ 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
+ 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+ 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+ 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+ 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+ 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+ 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+ 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+ 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
+};
+
+int yaffs_hweight8(u8 x)
+{
+ int ret_val;
+ ret_val = yaffs_count_bits_table[x];
+ return ret_val;
+}
+
+int yaffs_hweight32(u32 x)
+{
+ return hweight8(x & 0xff) +
+ hweight8((x >> 8) & 0xff) +
+ hweight8((x >> 16) & 0xff) +
+ hweight8((x >> 24) & 0xff);
+}
+
--- /dev/null
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ * for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __YAFFS_HWEIGHT_H__
+#define __YAFFS_HWEIGHT_H__
+
+#include "yportenv.h"
+
+int yaffs_hweight8(u8 x);
+int yaffs_hweight32(u32 x);
+
+#endif
#include "stdio.h"
#include "string.h"
#include "yaffs_osglue.h"
+#include "yaffs_hweight.h"
#include "assert.h"
#define YBUG() assert(0)
#define yaffs_sprintf sprintf
#define yaffs_toupper(a) toupper(a)
+#define hweight8(x) yaffs_hweight8(x)
+#define hweight32(x) yaffs_hweight32(x)
+
void yaffs_qsort(void *aa, size_t n, size_t es,
int (*cmp)(const void *, const void *));
#include "yaffs_list.h"
-
#include "yaffsfs.h"
#endif
0x69, 0x3c, 0x30, 0x65, 0x0c, 0x59, 0x55, 0x00,
};
-/* Count the bits in an unsigned char or a U32 */
-
-static int yaffs_count_bits(unsigned char x)
-{
- int r = 0;
- while (x) {
- if (x & 1)
- r++;
- x >>= 1;
- }
- return r;
-}
-
-static int yaffs_count_bits32(unsigned x)
-{
- int r = 0;
- while (x) {
- if (x & 1)
- r++;
- x >>= 1;
- }
- return r;
-}
/* Calculate the ECC for a 256-byte block of data */
void yaffs_ecc_cacl(const unsigned char *data, unsigned char *ecc)
return 1; /* Corrected the error */
}
- if ((yaffs_count_bits(d0) +
- yaffs_count_bits(d1) + yaffs_count_bits(d2)) == 1) {
+ if ((hweight8(d0) + hweight8(d1) + hweight8(d2)) == 1) {
/* Reccoverable error in ecc */
read_ecc[0] = test_ecc[0];
return 1; /* corrected */
}
- if ((yaffs_count_bits32(delta_line) +
- yaffs_count_bits32(delta_line_prime) +
- yaffs_count_bits(delta_col)) == 1) {
+ if ((hweight32(delta_line) +
+ hweight32(delta_line_prime) +
+ hweight8(delta_col)) == 1) {
/* Reccoverable error in ecc */
*read_ecc = *test_ecc;
static void yaffs_handle_rd_data_error(struct yaffs_dev *dev, int nand_chunk);
-static const char yaffs_count_bits_table[256] = {
- 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
- 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
- 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
-};
-
-int yaffs_count_bits(u8 x)
-{
- int ret_val;
- ret_val = yaffs_count_bits_table[x];
- return ret_val;
-}
/********** Tags ECC calculations *********/
if (ext_tags) {
int deleted =
- (yaffs_count_bits(spare.page_status) < 7) ? 1 : 0;
+ (hweight8(spare.page_status) < 7) ? 1 : 0;
ext_tags->is_deleted = deleted;
ext_tags->ecc_result = ecc_result;
yaffs_rd_chunk_nand(dev, block_no * dev->param.chunks_per_block + 1,
NULL, &spare1, &dummy, 1);
- if (yaffs_count_bits(spare0.block_status & spare1.block_status) < 7)
+ if (hweight8(spare0.block_status & spare1.block_status) < 7)
*state = YAFFS_BLOCK_STATE_DEAD;
else if (memcmp(&spare_ff, &spare0, sizeof(spare_ff)) == 0)
*state = YAFFS_BLOCK_STATE_EMPTY;
#include <linux/fs.h>
#include <linux/stat.h>
#include <linux/sort.h>
+#include <linux/bitops.h>
#define YCHAR char
#define YUCHAR unsigned char
#include <linux/fs.h>
#include <linux/stat.h>
#include <linux/sort.h>
+#include <linux/bitops.h>
#define YCHAR char
#define YUCHAR unsigned char