*/
//yaffs_guts.c
-const char *yaffs_guts_c_version="$Id: yaffs_guts.c,v 1.14 2002-12-04 19:12:43 charles Exp $";
+const char *yaffs_guts_c_version="$Id: yaffs_guts.c,v 1.15 2002-12-13 00:13:06 charles Exp $";
#include "yportenv.h"
#ifndef CONFIG_YAFFS_USE_NANDECC
- retVal = dev->readChunkFromNAND(dev,chunkInNAND,data,spare);
- if(data && doErrorCorrection)
- {
- // Hoosterman, we had a data problem on this page
- yaffs_HandleReadDataError(dev,chunkInNAND);
- }
+ retVal = dev->readChunkFromNAND(dev,chunkInNAND,data,spare);
+ if(data && doErrorCorrection)
+ {
+ // Do ECC correction
+ //Todo handle any errors
+ nand_calculate_ecc(data,calcEcc);
+ eccResult1 = nand_correct_data (data,spare->ecc1, calcEcc);
+ nand_calculate_ecc(&data[256],calcEcc);
+ eccResult2 = nand_correct_data (&data[256],spare->ecc2, calcEcc);
+
+ if(eccResult1>0)
+ {
+ T(YAFFS_TRACE_ERROR, (TSTR("**>>ecc error fix performed on chunk %d:0" TENDSTR),chunkInNAND));
+ dev->eccFixed++;
+ }
+ else if(eccResult1<0)
+ {
+ T(YAFFS_TRACE_ERROR,(TSTR("**>>ecc error unfixed on chunk %d:0" TENDSTR),chunkInNAND));
+ dev->eccUnfixed++;
+ }
+
+ if(eccResult2>0)
+ {
+ T(YAFFS_TRACE_ERROR,(TSTR("**>>ecc error fix performed on chunk %d:1" TENDSTR),chunkInNAND));
+ dev->eccFixed++;
+ }
+ else if(eccResult2<0)
+ {
+ T(YAFFS_TRACE_ERROR,(TSTR("**>>ecc error unfixed on chunk %d:1" TENDSTR),chunkInNAND));
+ dev->eccUnfixed++;
+ }
+
+ if(eccResult1 || eccResult2)
+ {
+ // Hoosterman, we had a data problem on this page
+ yaffs_HandleReadDataError(dev,chunkInNAND);
+ }
+ }
#else
retVal = dev->readChunkFromNAND(dev,chunkInNAND,data,(yaffs_Spare*)&nspare);
memcpy (spare, &nspare, sizeof(yaffs_Spare));
for(i = dev->startBlock; i <= dev->endBlock; i++)
{
- bi = yaffs_GetBlockInfo(dev,i);
+ dev->allocationBlockFinder++;
+ if(dev->allocationBlockFinder < dev->startBlock ||
+ dev->allocationBlockFinder > dev->endBlock)
+ {
+ dev->allocationBlockFinder = dev->startBlock;
+ }
+
+ bi = yaffs_GetBlockInfo(dev,dev->allocationBlockFinder);
if(bi->blockState == YAFFS_BLOCK_STATE_EMPTY)
{
bi->blockState = YAFFS_BLOCK_STATE_ALLOCATING;
dev->nErasedBlocks--;
- return i;
+ return dev->allocationBlockFinder;
}
}